Have add item default to adding an int of value 0

This commit is contained in:
Neel Goyal 2013-12-09 14:11:17 -05:00
parent 969ce94358
commit 7db1610c95
1 changed files with 7 additions and 5 deletions

View File

@ -1,7 +1,7 @@
/** /**
* *
* /brief getdns list management functions * /brief getdns list management functions
* *
* This is the meat of the API * This is the meat of the API
* Originally taken from the getdns API description pseudo implementation. * Originally taken from the getdns API description pseudo implementation.
* *
@ -10,7 +10,7 @@
/* /*
* Copyright (c) 2013, Versign, Inc. * Copyright (c) 2013, Versign, Inc.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
@ -100,7 +100,7 @@ getdns_list_get_bindata(struct getdns_list * list, size_t index,
{ {
if (!list || index >= list->numinuse) if (!list || index >= list->numinuse)
return GETDNS_RETURN_NO_SUCH_LIST_ITEM; return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
if (list->items[index].dtype != t_bindata) if (list->items[index].dtype != t_bindata)
return GETDNS_RETURN_WRONG_TYPE_REQUESTED; return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
@ -190,7 +190,7 @@ getdns_list_copy(struct getdns_list * srclist, struct getdns_list ** dstlist)
retval =getdns_list_set_list(*dstlist, index, retval =getdns_list_set_list(*dstlist, index,
srclist->items[i].data.list); srclist->items[i].data.list);
break; break;
case t_bindata: case t_bindata:
retval = getdns_list_set_bindata(*dstlist, index, retval = getdns_list_set_bindata(*dstlist, index,
srclist->items[i].data.bindata); srclist->items[i].data.bindata);
@ -231,7 +231,7 @@ getdns_list_create_with_extended_memory_functions(
sizeof(struct getdns_list)); sizeof(struct getdns_list));
if (!list) if (!list)
return NULL; return NULL;
list->mf.mf_arg = userarg; list->mf.mf_arg = userarg;
list->mf.mf.ext.malloc = malloc; list->mf.mf.ext.malloc = malloc;
list->mf.mf.ext.realloc = realloc; list->mf.mf.ext.realloc = realloc;
@ -337,6 +337,8 @@ getdns_list_add_item(struct getdns_list *list, size_t * index)
return retval; return retval;
} }
*index = list->numinuse; *index = list->numinuse;
list->items[*index].dtype = t_int;
list->items[*index].data.n = 0;
list->numinuse++; list->numinuse++;
return GETDNS_RETURN_GOOD; return GETDNS_RETURN_GOOD;
} /* getdns_list_add_item */ } /* getdns_list_add_item */