The function prototype:
char * get_something();
Now we need to free the memory allocated by "get_something" function.
delete or delete []?
we have no information about the impl of the function -- array of char or single char
You can't tell.
And the author of the function should have known better than to return a pointer to allocated memory like this.
Even if you did find out (by consulting the documentation perhaps?), you'd have to make sure that your code was compiled in exactly the same way as that function. If your delete
runtime is different from their new
runtime then merry hell will ensue.
Your best bet is to badger the library vendor to provide you with a release_something(char*)
function that clears the memory for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With