Diff for /embedaddon/quagga/isisd/dict.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 17:26:11 version 1.1.1.2, 2012/10/09 09:22:28
Line 15 Line 15
  * contain a copyright notice related to this source.   * contain a copyright notice related to this source.
  */   */
   
 #include <stdlib.h>  
 #include <stddef.h>  
 #include "zebra.h"  #include "zebra.h"
 #include "zassert.h"  #include "zassert.h"
#define DICT_IMPLEMENTATION#include "memory.h"
 #include "dict.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,   * These macros provide short convenient names for structure members,
  * which are embellished with dict_ prefixes so that they are   * which are embellished with dict_ prefixes so that they are
Line 243  static int verify_dict_has_node(dnode_t *nil, dnode_t  Line 237  static int verify_dict_has_node(dnode_t *nil, dnode_t 
   
 dict_t *dict_create(dictcount_t maxcount, dict_comp_t comp)  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) {      if (new) {
         new->compare = comp;          new->compare = comp;
Line 284  void dict_set_allocator(dict_t *dict, dnode_alloc_t al Line 278  void dict_set_allocator(dict_t *dict, dnode_alloc_t al
 void dict_destroy(dict_t *dict)  void dict_destroy(dict_t *dict)
 {  {
     assert (dict_isempty(dict));      assert (dict_isempty(dict));
    free(dict);    XFREE(MTYPE_ISIS_DICT, dict);
 }  }
   
 /*  /*
Line 307  void dict_free_nodes(dict_t *dict) Line 301  void dict_free_nodes(dict_t *dict)
   
 void dict_free(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);      dict_free_nodes(dict);
 }  }
   
Line 810  dnode_t *dict_delete(dict_t *dict, dnode_t *delete) Line 801  dnode_t *dict_delete(dict_t *dict, dnode_t *delete)
   
 int dict_alloc_insert(dict_t *dict, const void *key, void *data)  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) {      if (node) {
         dnode_init(node, data);          dnode_init(node, data);
Line 946  int dict_contains(dict_t *dict, dnode_t *node) Line 937  int dict_contains(dict_t *dict, dnode_t *node)
   
 static dnode_t *dnode_alloc(void *context)  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)  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 *dnode_create(void *data)
 {  {
    dnode_t *new = malloc(sizeof *new);    dnode_t *new = XCALLOC(MTYPE_ISIS_DICT_NODE, sizeof(dnode_t));
     if (new) {      if (new) {
         new->data = data;          new->data = data;
         new->parent = NULL;          new->parent = NULL;
Line 978  dnode_t *dnode_init(dnode_t *dnode, void *data) Line 969  dnode_t *dnode_init(dnode_t *dnode, void *data)
 void dnode_destroy(dnode_t *dnode)  void dnode_destroy(dnode_t *dnode)
 {  {
     assert (!dnode_is_in_a_dict(dnode));      assert (!dnode_is_in_a_dict(dnode));
    free(dnode);    XFREE(MTYPE_ISIS_DICT_NODE, dnode);
 }  }
   
 void *dnode_get(dnode_t *dnode)  void *dnode_get(dnode_t *dnode)
Line 1232  static int comparef(const void *key1, const void *key2 Line 1223  static int comparef(const void *key1, const void *key2
 static char *dupstring(char *str)  static char *dupstring(char *str)
 {  {
     int sz = strlen(str) + 1;      int sz = strlen(str) + 1;
    char *new = malloc(sz);    char *new = XCALLOC(MTYPE_ISIS_TMP, sz);
     if (new)      if (new)
         memcpy(new, str, sz);          memcpy(new, str, sz);
     return new;      return new;
Line 1347  int main(void) Line 1338  int main(void)
         "s                      switch to non-functioning allocator\n"          "s                      switch to non-functioning allocator\n"
         "q                      quit";          "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);          dict_init(&darray[i], DICTCOUNT_T_MAX, comparef);
   
     for (;;) {      for (;;) {

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>