]> andersk Git - splint.git/blobdiff - src/cstringTable.c
Fixed problem with NULL being changed.
[splint.git] / src / cstringTable.c
index 5eeb122f9dbf14297d2f7c4dad8fdad935e00115..8799591138d2880972eee3e78b334f23ff0ac35e 100644 (file)
@@ -55,8 +55,7 @@ static hentry hentry_create (/*@only@*/ cstring key, int val)
 
   h->key = key;
   h->val = val;
-  llassert (val != HBUCKET_DNE); /*@i523 way bogus! */
-
+  llassert (val != HBUCKET_DNE); 
   return (h);
 }
 
@@ -116,12 +115,13 @@ hbucket_grow (/*@notnull@*/ hbucket h)
   
   for (i = 0; i < h->size; i++) 
     {
-          newentries[i] = h->entries[i]; 
+      newentries[i] = h->entries[i]; 
     }
  
-  /*@i32@*/ sfree (h->entries);
+  sfree (h->entries);
   h->entries = newentries; 
-/*@i23@*/ }
+  /*@-compmempass@*/
+} /*@=compmempass@*/ /* Spurious warnings reported - shouldn't need this */
 
 static int hbucket_lookup (hbucket p_h, cstring p_key);
 
@@ -200,7 +200,7 @@ void hbucket_free (/*@only@*/ hbucket h)
 void 
 cstringTable_free (/*@only@*/ cstringTable h)
 {
-  int i;
+  unsigned long i;
 
   llassert (cstringTable_isDefined (h)); 
 
@@ -217,7 +217,7 @@ static int
 cstringTable_countCollisions (cstringTable h)
 {
   int nc = 0;
-  int i;
+  unsigned long i;
 
   llassert (cstringTable_isDefined (h)); 
 
@@ -234,7 +234,7 @@ static int
 cstringTable_countEmpty (cstringTable h)
 {
   int nc = 0;
-  int i;
+  unsigned long i;
 
   llassert (cstringTable_isDefined (h)); 
 
@@ -276,9 +276,9 @@ cstringTable_hash (/*@notnull@*/ cstringTable h, cstring key)
 
 
 /*@only@*/ cstringTable
-cstringTable_create (int size)
+cstringTable_create (unsigned long size)
 {
-  int i;
+  unsigned long i;
   cstringTable h = (cstringTable) dmalloc (sizeof (*h));
   
   h->size = size;
@@ -297,7 +297,7 @@ cstringTable_create (int size)
 cstring cstringTable_unparse (cstringTable h)
 {
   cstring res = cstring_newEmpty ();
-  int i;
+  unsigned long i;
 
   if (cstringTable_isDefined (h)) 
     {
@@ -307,11 +307,11 @@ cstring cstringTable_unparse (cstringTable h)
          
          if (hb != NULL)
            {
-             res = message ("%q%d. %q\n", res, i, hbucket_unparse (hb));
+             res = message ("%q%wl. %q\n", res, i, hbucket_unparse (hb));
            }
        }
       
-      res = message ("%qsize: %d, collisions: %d, empty: %d", 
+      res = message ("%qsize: %wl, collisions: %d, empty: %d", 
                     res,
                     h->size, 
                     cstringTable_countCollisions (h),
@@ -331,7 +331,7 @@ cstring cstringTable_unparse (cstringTable h)
 cstringTable_stats (cstringTable h)
 {
   llassert (cstringTable_isDefined (h)); 
-  return (message ("size: %d, collisions: %d, empty: %d\n", 
+  return (message ("size: %wl, collisions: %d, empty: %d\n", 
                   h->size, cstringTable_countCollisions (h),
                   cstringTable_countEmpty (h)));
 }
@@ -343,9 +343,10 @@ cstringTable_rehash (/*@notnull@*/ cstringTable h)
   ** rehashing based (loosely) on code by Steve Harrison
   */
 
-  int i;
-  int oldsize = h->size;
-  int newsize = 1 + ((oldsize * 26244) / 10000); /* 26244 = 162^2 */
+  unsigned long i;
+  /* Fix provided by Thomas Mertz (int -> unsigned long), 21 Apr 2004 */
+  unsigned long oldsize = h->size;
+  unsigned long newsize = 1 + ((oldsize * 26244) / 10000); /* 26244 = 162^2 */
   hbucket *oldbuckets = h->buckets;
   
   h->size = newsize;  
@@ -423,7 +424,7 @@ cstringTable_addEntry (/*@notnull@*/ cstringTable h, /*@only@*/ hentry e)
 void
 cstringTable_insert (cstringTable h, cstring key, int value)
 {
-  unsigned int hindex;
+  unsigned long hindex;
   hbucket hb;
   hentry e;  
 
This page took 0.04958 seconds and 4 git commands to generate.