mirror of https://github.com/getdnsapi/getdns.git
make setter "child" values const
Because they're copied and thus not altered
This commit is contained in:
parent
20853601a6
commit
d118ccc31e
12
src/dict.c
12
src/dict.c
|
@ -283,7 +283,8 @@ getdns_dict_create()
|
|||
* @return NULL on error (out of memory, invalid srcdict)
|
||||
*/
|
||||
getdns_return_t
|
||||
getdns_dict_copy(struct getdns_dict * srcdict, struct getdns_dict ** dstdict)
|
||||
getdns_dict_copy(const struct getdns_dict * srcdict,
|
||||
struct getdns_dict ** dstdict)
|
||||
{
|
||||
struct getdns_dict_item *item;
|
||||
char *key;
|
||||
|
@ -305,7 +306,8 @@ getdns_dict_copy(struct getdns_dict * srcdict, struct getdns_dict ** dstdict)
|
|||
return GETDNS_RETURN_GENERIC_ERROR;
|
||||
|
||||
retval = GETDNS_RETURN_GOOD;
|
||||
LDNS_RBTREE_FOR(item, struct getdns_dict_item *, &(srcdict->root)) {
|
||||
LDNS_RBTREE_FOR(item, struct getdns_dict_item *,
|
||||
(struct ldns_rbtree_t *)&(srcdict->root)) {
|
||||
key = (char *) item->node.key;
|
||||
switch (item->dtype) {
|
||||
case t_bindata:
|
||||
|
@ -385,7 +387,7 @@ getdns_dict_destroy(struct getdns_dict *dict)
|
|||
/*---------------------------------------- getdns_dict_set_dict */
|
||||
getdns_return_t
|
||||
getdns_dict_set_dict(struct getdns_dict * dict, const char *name,
|
||||
struct getdns_dict * child_dict)
|
||||
const struct getdns_dict * child_dict)
|
||||
{
|
||||
struct getdns_dict_item *item;
|
||||
struct getdns_dict *newdict;
|
||||
|
@ -411,7 +413,7 @@ getdns_dict_set_dict(struct getdns_dict * dict, const char *name,
|
|||
/*---------------------------------------- getdns_dict_set_list */
|
||||
getdns_return_t
|
||||
getdns_dict_set_list(struct getdns_dict * dict, const char *name,
|
||||
struct getdns_list * child_list)
|
||||
const struct getdns_list * child_list)
|
||||
{
|
||||
struct getdns_dict_item *item;
|
||||
struct getdns_list *newlist;
|
||||
|
@ -437,7 +439,7 @@ getdns_dict_set_list(struct getdns_dict * dict, const char *name,
|
|||
/*---------------------------------------- getdns_dict_set_bindata */
|
||||
getdns_return_t
|
||||
getdns_dict_set_bindata(struct getdns_dict * dict, const char *name,
|
||||
struct getdns_bindata * child_bindata)
|
||||
const struct getdns_bindata * child_bindata)
|
||||
{
|
||||
struct getdns_dict_item *item;
|
||||
struct getdns_bindata *newbindata;
|
||||
|
|
|
@ -609,7 +609,7 @@ void getdns_list_destroy(struct getdns_list *this_list);
|
|||
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if index is out of range, or list is NULL
|
||||
*/
|
||||
getdns_return_t getdns_list_set_dict(struct getdns_list *this_list, size_t index,
|
||||
struct getdns_dict *child_dict);
|
||||
const struct getdns_dict *child_dict);
|
||||
|
||||
/**
|
||||
* assign the child_list to an item in a parent list, the parent list copies
|
||||
|
@ -621,7 +621,7 @@ getdns_return_t getdns_list_set_dict(struct getdns_list *this_list, size_t index
|
|||
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if index is out of range, or list is NULL
|
||||
*/
|
||||
getdns_return_t getdns_list_set_list(struct getdns_list *this_list, size_t index,
|
||||
struct getdns_list *child_list);
|
||||
const struct getdns_list *child_list);
|
||||
/**
|
||||
* assign the child_bindata to an item in a parent list, the parent list copies
|
||||
* the child data and will free the copy when the list is destroyed
|
||||
|
@ -632,7 +632,7 @@ getdns_return_t getdns_list_set_list(struct getdns_list *this_list, size_t index
|
|||
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if index is out of range, or list is NULL
|
||||
*/
|
||||
getdns_return_t getdns_list_set_bindata(struct getdns_list *this_list, size_t index,
|
||||
struct getdns_bindata *child_bindata);
|
||||
const struct getdns_bindata *child_bindata);
|
||||
/**
|
||||
* set the integer value of the indexed item (zero based index)
|
||||
* @return GETDNS_RETURN_GOOD on success
|
||||
|
@ -666,8 +666,8 @@ struct getdns_dict *getdns_dict_create_with_extended_memory_functions(
|
|||
*/
|
||||
void getdns_dict_destroy(struct getdns_dict *this_dict);
|
||||
|
||||
getdns_return_t getdns_dict_set_dict(struct getdns_dict *this_dict, const char *name,
|
||||
struct getdns_dict *child_dict);
|
||||
getdns_return_t getdns_dict_set_dict(struct getdns_dict *this_dict,
|
||||
const char *name, const struct getdns_dict *child_dict);
|
||||
/**
|
||||
* create a new entry in the dictionary, or replace the value of an existing entry
|
||||
* this routine makes a copy of the child_list
|
||||
|
@ -676,8 +676,8 @@ getdns_return_t getdns_dict_set_dict(struct getdns_dict *this_dict, const char *
|
|||
* @param child_list value to assign to the node identified by name
|
||||
* @return GETDNS_RETURN_GOOD on success
|
||||
*/
|
||||
getdns_return_t getdns_dict_set_list(struct getdns_dict *this_dict, const char *name,
|
||||
struct getdns_list *child_list);
|
||||
getdns_return_t getdns_dict_set_list(struct getdns_dict *this_dict,
|
||||
const char *name, const struct getdns_list *child_list);
|
||||
/**
|
||||
* create a new entry in the dictionary, or replace the value of an existing entry
|
||||
* this routine makes a copy of the child_bindata
|
||||
|
@ -686,8 +686,8 @@ getdns_return_t getdns_dict_set_list(struct getdns_dict *this_dict, const char *
|
|||
* @param child_bindata value to assign to the node identified by name
|
||||
* @return GETDNS_RETURN_GOOD on success
|
||||
*/
|
||||
getdns_return_t getdns_dict_set_bindata(struct getdns_dict *this_dict, const char *name,
|
||||
struct getdns_bindata *child_bindata);
|
||||
getdns_return_t getdns_dict_set_bindata(struct getdns_dict *this_dict,
|
||||
const char *name, const struct getdns_bindata *child_bindata);
|
||||
/**
|
||||
* create a new entry in the dictionary, or replace the value of an existing entry
|
||||
* @param this_dict dictionary in which to add or change the value
|
||||
|
|
|
@ -167,7 +167,8 @@ getdns_list_realloc(struct getdns_list *list)
|
|||
|
||||
/*---------------------------------------- getdns_list_copy */
|
||||
getdns_return_t
|
||||
getdns_list_copy(struct getdns_list * srclist, struct getdns_list ** dstlist)
|
||||
getdns_list_copy(const struct getdns_list * srclist,
|
||||
struct getdns_list ** dstlist)
|
||||
{
|
||||
int i;
|
||||
size_t index;
|
||||
|
@ -362,7 +363,7 @@ getdns_list_add_item(struct getdns_list *list, size_t * index)
|
|||
/*---------------------------------------- getdns_list_set_dict */
|
||||
getdns_return_t
|
||||
getdns_list_set_dict(struct getdns_list * list, size_t index,
|
||||
struct getdns_dict * child_dict)
|
||||
const struct getdns_dict * child_dict)
|
||||
{
|
||||
struct getdns_dict *newdict;
|
||||
getdns_return_t retval;
|
||||
|
@ -394,7 +395,7 @@ getdns_list_set_dict(struct getdns_list * list, size_t index,
|
|||
/*---------------------------------------- getdns_list_set_list */
|
||||
getdns_return_t
|
||||
getdns_list_set_list(struct getdns_list * list, size_t index,
|
||||
struct getdns_list * child_list)
|
||||
const struct getdns_list * child_list)
|
||||
{
|
||||
struct getdns_list *newlist;
|
||||
getdns_return_t retval;
|
||||
|
@ -426,7 +427,7 @@ getdns_list_set_list(struct getdns_list * list, size_t index,
|
|||
/*---------------------------------------- getdns_list_set_bindata */
|
||||
getdns_return_t
|
||||
getdns_list_set_bindata(struct getdns_list * list, size_t index,
|
||||
struct getdns_bindata * child_bindata)
|
||||
const struct getdns_bindata * child_bindata)
|
||||
{
|
||||
struct getdns_bindata *newbindata;
|
||||
getdns_return_t retval;
|
||||
|
|
|
@ -70,7 +70,7 @@ getdns_return_t getdns_list_add_item(struct getdns_list *list, size_t * index);
|
|||
* @return GETDNS_RETURN_NO_SUCH_LIST_ITEM if list is invalid
|
||||
* @return GETDNS_RETURN_GENERIC_ERROR if out of memory
|
||||
*/
|
||||
getdns_return_t getdns_list_copy(struct getdns_list *srclist,
|
||||
getdns_return_t getdns_list_copy(const struct getdns_list *srclist,
|
||||
struct getdns_list **dstlist);
|
||||
|
||||
/**
|
||||
|
@ -82,7 +82,8 @@ getdns_return_t getdns_list_copy(struct getdns_list *srclist,
|
|||
* @return GETDNS_RETURN_GOOD on success
|
||||
*/
|
||||
getdns_return_t
|
||||
getdns_dict_copy(struct getdns_dict *srcdict, struct getdns_dict **dstdict);
|
||||
getdns_dict_copy(const struct getdns_dict *srcdict,
|
||||
struct getdns_dict **dstdict);
|
||||
|
||||
/**
|
||||
* convert an ip address (v4/v6) dict to a sock storage
|
||||
|
|
Loading…
Reference in New Issue