gdb: Fix build failure with GCC 7
[deliverable/binutils-gdb.git] / gdb / bcache.c
index 2a180af6053de15afb8eecb1cef535b53650cf82..06ab843d3ac6fe4ebdadd866f4c81f85565c0a58 100644 (file)
@@ -2,8 +2,7 @@
    Written by Fred Fish <fnf@cygnus.com>
    Rewritten by Jim Blandy <jimb@cygnus.com>
 
-   Copyright (C) 1999-2000, 2002-2003, 2007-2012 Free Software
-   Foundation, Inc.
+   Copyright (C) 1999-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "defs.h"
 #include "gdb_obstack.h"
 #include "bcache.h"
-#include "gdb_string.h"                /* For memcpy declaration */
-#include "gdb_assert.h"
-
-#include <stddef.h>
-#include <stdlib.h>
 
 /* The type used to hold a single bcache string.  The user data is
    stored in d.data.  Since it can be any type, it needs to have the
@@ -270,14 +264,15 @@ bcache_full (const void *addr, int length, struct bcache *bcache, int *added)
 
   /* The user's string isn't in the list.  Insert it after *ps.  */
   {
-    struct bstring *new
-      = obstack_alloc (&bcache->cache, BSTRING_SIZE (length));
+    struct bstring *newobj
+      = (struct bstring *) obstack_alloc (&bcache->cache,
+                                         BSTRING_SIZE (length));
 
-    memcpy (&new->d.data, addr, length);
-    new->length = length;
-    new->next = bcache->bucket[hash_index];
-    new->half_hash = half_hash;
-    bcache->bucket[hash_index] = new;
+    memcpy (&newobj->d.data, addr, length);
+    newobj->length = length;
+    newobj->next = bcache->bucket[hash_index];
+    newobj->half_hash = half_hash;
+    bcache->bucket[hash_index] = newobj;
 
     bcache->unique_count++;
     bcache->unique_size += length;
@@ -286,7 +281,7 @@ bcache_full (const void *addr, int length, struct bcache *bcache, int *added)
     if (added)
       *added = 1;
 
-    return &new->d.data;
+    return &newobj->d.data;
   }
 }
 \f
@@ -314,7 +309,7 @@ bcache_xmalloc (unsigned long (*hash_function)(const void *, int length),
                                        int length))
 {
   /* Allocate the bcache pre-zeroed.  */
-  struct bcache *b = XCALLOC (1, struct bcache);
+  struct bcache *b = XCNEW (struct bcache);
 
   if (hash_function)
     b->hash_function = hash_function;
@@ -361,7 +356,7 @@ print_percentage (int portion, int total)
    BCACHE holds.  Statistics are printed using `printf_filtered' and
    its ilk.  */
 void
-print_bcache_statistics (struct bcache *c, char *type)
+print_bcache_statistics (struct bcache *c, const char *type)
 {
   int occupied_buckets;
   int max_chain_length;
@@ -373,8 +368,8 @@ print_bcache_statistics (struct bcache *c, char *type)
      lengths, and measure chain lengths.  */
   {
     unsigned int b;
-    int *chain_length = XCALLOC (c->num_buckets + 1, int);
-    int *entry_size = XCALLOC (c->unique_count + 1, int);
+    int *chain_length = XCNEWVEC (int, c->num_buckets + 1);
+    int *entry_size = XCNEWVEC (int, c->unique_count + 1);
     int stringi = 0;
 
     occupied_buckets = 0;
This page took 0.029284 seconds and 4 git commands to generate.