M
Matt Garman
If I have a C++ function that returns dynamically allocated memory using
the new operator, must that memory be freed using the delete operator,
or is it okay to use free()?
My function will have a C wrapper interface. Since I can't use delete
in C, is it okay to just use free()? Or should I go ahead and write
another C++ function that will free the memory using delete?
My instincts tell me it's probably bad to mix new and free(), if not for
technical reasons, then for code readability reasons.
Thanks!
Matt
the new operator, must that memory be freed using the delete operator,
or is it okay to use free()?
My function will have a C wrapper interface. Since I can't use delete
in C, is it okay to just use free()? Or should I go ahead and write
another C++ function that will free the memory using delete?
My instincts tell me it's probably bad to mix new and free(), if not for
technical reasons, then for code readability reasons.
Thanks!
Matt