gdb/
[binutils-gdb.git] / gdb / bcache.c
index d56df07e4c8d8899bfb0be9c7fd2bb054876e5d8..7d9180cbec3c36ca56dc2bf5276049d569979a22 100644 (file)
@@ -2,7 +2,7 @@
    Written by Fred Fish <fnf@cygnus.com>
    Rewritten by Jim Blandy <jimb@cygnus.com>
 
-   Copyright (C) 1999, 2000, 2002, 2003, 2007, 2008, 2009
+   Copyright (C) 1999, 2000, 2002, 2003, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -98,17 +98,17 @@ struct bcache
 unsigned long
 hash(const void *addr, int length)
 {
-               const unsigned char *k, *e;
-               unsigned long h;
-               
-               k = (const unsigned char *)addr;
-               e = k+length;
-               for (h=0; k< e;++k)
-               {
-                               h *=16777619;
-                               h ^= *k;
-               }
-               return (h);
+  const unsigned char *k, *e;
+  unsigned long h;
+
+  k = (const unsigned char *)addr;
+  e = k+length;
+  for (h=0; k< e;++k)
+    {
+      h *=16777619;
+      h ^= *k;
+    }
+  return (h);
 }
 \f
 /* Growing the bcache's hash table.  */
@@ -152,6 +152,7 @@ expand_hash_table (struct bcache *bcache)
   /* Allocate the new table.  */
   {
     size_t new_size = new_num_buckets * sizeof (new_buckets[0]);
+
     new_buckets = (struct bstring **) xmalloc (new_size);
     memset (new_buckets, 0, new_size);
 
@@ -257,6 +258,7 @@ bcache_full (const void *addr, int length, struct bcache *bcache, int *added)
   {
     struct bstring *new
       = obstack_alloc (&bcache->cache, BSTRING_SIZE (length));
+
     memcpy (&new->d.data, addr, length);
     new->length = length;
     new->next = bcache->bucket[hash_index];
@@ -281,6 +283,7 @@ bcache_xmalloc (void)
 {
   /* Allocate the bcache pre-zeroed.  */
   struct bcache *b = XCALLOC (1, struct bcache);
+
   return b;
 }
 
@@ -301,15 +304,6 @@ bcache_xfree (struct bcache *bcache)
 \f
 /* Printing statistics.  */
 
-static int
-compare_ints (const void *ap, const void *bp)
-{
-  /* Because we know we're comparing two ints which are positive,
-     there's no danger of overflow here.  */
-  return * (int *) ap - * (int *) bp;
-}
-
-
 static void
 print_percentage (int portion, int total)
 {
@@ -367,9 +361,9 @@ print_bcache_statistics (struct bcache *c, char *type)
 
     /* To compute the median, we need the set of chain lengths sorted.  */
     qsort (chain_length, c->num_buckets, sizeof (chain_length[0]),
-          compare_ints);
+          compare_positive_ints);
     qsort (entry_size, c->unique_count, sizeof (entry_size[0]),
-          compare_ints);
+          compare_positive_ints);
 
     if (c->num_buckets > 0)
       {