[cxx-abi-dev] __cxa_demangle memory ownership issue

Howard Hinnant hinnant at twcny.rr.com
Thu Jan 20 14:07:40 UTC 2011


On Jan 20, 2011, at 1:31 AM, Dennis Handly wrote:

>> From: Howard Hinnant <hhinnant at apple.com>
>> char* __cxa_demangle(const char* mangled_name, char* buf, size_t* n,
>> 				   int* status);
> 
>> If buf and n are non-null and if __cxa_demangle returns NULL (e.g.
>> because of an invalid mangled_name), does __cxa_demangle free(buf) or
>> not?  The spec seems ambiguous on this point.
> 
> My implementation never frees anything unless it is too small.
> 
> The spec isn't ambiguous if you assume you do ONLY what is mentioned under
> Memory management.

Ok, thanks.

I guess it seemed ambiguous to me only because I'm used to C++ memory ownership patterns and I thought of the client passing ownership in buf and receiving it back in the return value (e.g. like you would do with auto_ptr).

-Howard




More information about the cxx-abi-dev mailing list