[getdns-api] Memory part 2 - get and set (side note proposal)

Willem Toorop willem at nlnetlabs.nl
Tue Jan 21 02:44:46 MST 2014


op 21-01-14 10:41, Willem Toorop schreef:
>> For the setters I propose this text to be the last paragraph of section 2.1:
> 
>  	The helper setter functions store copies of the given "child"
>  	values.  It is the responsibility of the caller to dispose of
> 	the original values.

Side note proposal:
The proposed memory strategy would most clearly be expressed by the
prototypes, with the given child value parameters const.  The same for
the looked up names in dicts.  The prototype would become:

getdns_return_t
getdns_list_set_dict(struct getdns_list *this_list, size_t index,
    const struct getdns_dict *child_dict);

getdns_return_t
getdns_list_set_list(struct getdns_list *this_list, size_t index,
    const struct getdns_list *child_list);

getdns_return_t
getdns_list_set_bindata(struct getdns_list *this_list, size_t index,
    const struct getdns_bindata *child_bindata);


getdns_return_t
getdns_dict_set_dict(struct getdns_dict *this_dict, const char *name,
    const struct getdns_dict *child_dict);

getdns_return_t
getdns_dict_set_list(struct getdns_dict *this_dict, const char *name,
    const struct getdns_list *child_list);

getdns_return_t
getdns_dict_set_bindata(struct getdns_dict *this_dict,
    const char *name, const struct getdns_bindata *child_bindata);

getdns_return_t
getdns_dict_set_int(struct getdns_dict *this_dict, const char *name,
    uint32_t child_uint32);

getdns_return_t getdns_dict_remove_name(struct getdns_dict *this_dict,
    const char *name);


What do you think?


More information about the getdns-api mailing list