[getdns-api] Memory part 3 - more Helper functions

Willem Toorop willem at nlnetlabs.nl
Tue Jan 21 02:54:08 MST 2014


Most helper functions in section 7 return char *:

char * getdns_convert_ulabel_to_alabel( const char *ulabel );
char * getdns_convert_alabel_to_ulabel( const char *alabel );
char * getdns_pretty_print_dict( const struct getdns_dict *some_dict );
char * getdns_display_ip_address( const struct getdns_bindata
*bindata_of_ipv4_or_ipv6_address );

The caller should destroy these values.

Because these function do not know about the custom memory functions,
the needed memory is allocated with malloc and should be freed with
free.  (not true for pretty_print_dict, but let's treat it the same for
consistency...)

I propose to append the following paragraph to section 7:

	All memory locations returned by these helper functions are
	allocated by the default system allocator (malloc).  The caller
	is responsible of disposing these allocations with free.


Furthermore, the examples should reflect this responsibility.
What do you think?


More information about the getdns-api mailing list