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

Willem Toorop willem at nlnetlabs.nl
Tue Jan 21 03:21:24 MST 2014


The same holds for the conversion functions in section 4.2:

char *getdns_convert_dns_name_to_fqdn(const char *fqdn_in_wire_format);
char *getdns_convert_fqdn_to_dns_name(const char *fqdn_as_string);

I propose to append to section 4.2:

 	The returned values are allocated with the default system
	allocator (malloc).  The caller is responsible of disposing
	these allocations with free.

And reflect this too in the examples.
Do you agree?


op 21-01-14 10:54, Willem Toorop schreef:
> 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?
> _______________________________________________
> getdns-api mailing list
> getdns-api at vpnc.org
> 



More information about the getdns-api mailing list