diff options
author | David Lamparter <equinox@diac24.net> | 2012-04-16 18:24:40 +0200 |
---|---|---|
committer | David Lamparter <equinox@diac24.net> | 2012-04-16 18:24:43 +0200 |
commit | d75318cc8de91d94649106f4ea3122d0d21ac9eb (patch) | |
tree | 6d7c674c4026bccd1384e60ee228d8d67750fbf7 /isisd/dict.c | |
parent | 6e493a44836d3b034ed3421e866878de3fbfcc5b (diff) | |
parent | 48d8bea8b7c83cf186460f711ab166455b5ed676 (diff) |
isisd: merge osr/google-is-is
this is essentially half of a rewrite of isisd. please note that a lot
of things are still broken and isisd is not ready for production use.
Diffstat (limited to 'isisd/dict.c')
-rw-r--r-- | isisd/dict.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/isisd/dict.c b/isisd/dict.c index a78b82ac..bbcb4213 100644 --- a/isisd/dict.c +++ b/isisd/dict.c @@ -15,17 +15,11 @@ * contain a copyright notice related to this source. */ -#include <stdlib.h> -#include <stddef.h> #include "zebra.h" #include "zassert.h" -#define DICT_IMPLEMENTATION +#include "memory.h" #include "dict.h" -#ifdef KAZLIB_RCSID -static const char rcsid[] = "Id: dict.c,v 1.40.2.7 2000/11/13 01:36:44 kaz"; -#endif - /* * These macros provide short convenient names for structure members, * which are embellished with dict_ prefixes so that they are @@ -243,7 +237,7 @@ static int verify_dict_has_node(dnode_t *nil, dnode_t *root, dnode_t *node) dict_t *dict_create(dictcount_t maxcount, dict_comp_t comp) { - dict_t *new = malloc(sizeof *new); + dict_t *new = XCALLOC(MTYPE_ISIS_DICT, sizeof(dict_t)); if (new) { new->compare = comp; @@ -284,7 +278,7 @@ void dict_set_allocator(dict_t *dict, dnode_alloc_t al, void dict_destroy(dict_t *dict) { assert (dict_isempty(dict)); - free(dict); + XFREE(MTYPE_ISIS_DICT, dict); } /* @@ -307,9 +301,6 @@ void dict_free_nodes(dict_t *dict) void dict_free(dict_t *dict) { -#ifdef KAZLIB_OBSOLESCENT_DEBUG - assert ("call to obsolescent function dict_free()" && 0); -#endif dict_free_nodes(dict); } @@ -810,7 +801,7 @@ dnode_t *dict_delete(dict_t *dict, dnode_t *delete) int dict_alloc_insert(dict_t *dict, const void *key, void *data) { - dnode_t *node = dict->allocnode(dict->context); + dnode_t *node = dict->allocnode (dict->context); if (node) { dnode_init(node, data); @@ -946,17 +937,17 @@ int dict_contains(dict_t *dict, dnode_t *node) static dnode_t *dnode_alloc(void *context) { - return malloc(sizeof *dnode_alloc(NULL)); + return XCALLOC(MTYPE_ISIS_DICT_NODE, sizeof(dnode_t)); } static void dnode_free(dnode_t *node, void *context) { - free(node); + XFREE(MTYPE_ISIS_DICT_NODE, node); } dnode_t *dnode_create(void *data) { - dnode_t *new = malloc(sizeof *new); + dnode_t *new = XCALLOC(MTYPE_ISIS_DICT_NODE, sizeof(dnode_t)); if (new) { new->data = data; new->parent = NULL; @@ -978,7 +969,7 @@ dnode_t *dnode_init(dnode_t *dnode, void *data) void dnode_destroy(dnode_t *dnode) { assert (!dnode_is_in_a_dict(dnode)); - free(dnode); + XFREE(MTYPE_ISIS_DICT_NODE, dnode); } void *dnode_get(dnode_t *dnode) @@ -1232,7 +1223,7 @@ static int comparef(const void *key1, const void *key2) static char *dupstring(char *str) { int sz = strlen(str) + 1; - char *new = malloc(sz); + char *new = XCALLOC(MTYPE_ISIS_TMP, sz); if (new) memcpy(new, str, sz); return new; @@ -1347,7 +1338,7 @@ int main(void) "s switch to non-functioning allocator\n" "q quit"; - for (i = 0; i < sizeof darray / sizeof *darray; i++) + for (i = 0; i < 10; i++) dict_init(&darray[i], DICTCOUNT_T_MAX, comparef); for (;;) { |