btrace: Fix memory leak in btrace_clear.
[deliverable/binutils-gdb.git] / gdb / dictionary.c
index 1829b1280782ec790efd8b203611523dcdc2ad56..e78db2ebe76757292a3c66311a1c35ed40dcd16d 100644 (file)
@@ -1,6 +1,6 @@
 /* Routines for name->symbol lookups in GDB.
    
-   Copyright (C) 2003-2015 Free Software Foundation, Inc.
+   Copyright (C) 2003-2017 Free Software Foundation, Inc.
 
    Contributed by David Carlton <carlton@bactrian.org> and by Kealia,
    Inc.
@@ -403,8 +403,8 @@ dict_create_hashed_expandable (void)
 
   DICT_VECTOR (retval) = &dict_hashed_expandable_vector;
   DICT_HASHED_NBUCKETS (retval) = DICT_EXPANDABLE_INITIAL_CAPACITY;
-  DICT_HASHED_BUCKETS (retval) = xcalloc (DICT_EXPANDABLE_INITIAL_CAPACITY,
-                                         sizeof (struct symbol *));
+  DICT_HASHED_BUCKETS (retval) = XCNEWVEC (struct symbol *,
+                                          DICT_EXPANDABLE_INITIAL_CAPACITY);
   DICT_HASHED_EXPANDABLE_NSYMS (retval) = 0;
 
   return retval;
@@ -467,11 +467,9 @@ dict_create_linear_expandable (void)
 
   DICT_VECTOR (retval) = &dict_linear_expandable_vector;
   DICT_LINEAR_NSYMS (retval) = 0;
-  DICT_LINEAR_EXPANDABLE_CAPACITY (retval)
-    = DICT_EXPANDABLE_INITIAL_CAPACITY;
+  DICT_LINEAR_EXPANDABLE_CAPACITY (retval) = DICT_EXPANDABLE_INITIAL_CAPACITY;
   DICT_LINEAR_SYMS (retval)
-    = xmalloc (DICT_LINEAR_EXPANDABLE_CAPACITY (retval)
-              * sizeof (struct symbol *));
+    = XNEWVEC (struct symbol *, DICT_LINEAR_EXPANDABLE_CAPACITY (retval));
 
   return retval;
 }
@@ -752,9 +750,8 @@ expand_hashtable (struct dictionary *dict)
 {
   int old_nbuckets = DICT_HASHED_NBUCKETS (dict);
   struct symbol **old_buckets = DICT_HASHED_BUCKETS (dict);
-  int new_nbuckets = 2*old_nbuckets + 1;
-  struct symbol **new_buckets = xcalloc (new_nbuckets,
-                                        sizeof (struct symbol *));
+  int new_nbuckets = 2 * old_nbuckets + 1;
+  struct symbol **new_buckets = XCNEWVEC (struct symbol *, new_nbuckets);
   int i;
 
   DICT_HASHED_NBUCKETS (dict) = new_nbuckets;
@@ -940,9 +937,8 @@ add_symbol_linear_expandable (struct dictionary *dict,
     {
       DICT_LINEAR_EXPANDABLE_CAPACITY (dict) *= 2;
       DICT_LINEAR_SYMS (dict)
-       = xrealloc (DICT_LINEAR_SYMS (dict),
-                   DICT_LINEAR_EXPANDABLE_CAPACITY (dict)
-                   * sizeof (struct symbol *));
+       = XRESIZEVEC (struct symbol *, DICT_LINEAR_SYMS (dict),
+                     DICT_LINEAR_EXPANDABLE_CAPACITY (dict));
     }
 
   DICT_LINEAR_SYM (dict, nsyms - 1) = sym;
This page took 0.036974 seconds and 4 git commands to generate.