]> andersk Git - splint.git/blobdiff - src/cstringTable.c
Fixed all /*@i...@*/ tags (except 1).
[splint.git] / src / cstringTable.c
index 640085cbad2b5688084e44bf650ed7fc2acd13aa..61be3f776642aaaf3f046a7b93dee6e2ecb021e2 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2001 University of Virginia,
+** Copyright (C) 1994-2003 University of Virginia,
 **         Massachusetts Institute of Technology
 **
 ** This program is free software; you can redistribute it and/or modify it
@@ -17,8 +17,8 @@
 ** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ** MA 02111-1307, USA.
 **
-** For information on lclint: lclint-request@cs.virginia.edu
-** To report a bug: lclint-bug@cs.virginia.edu
+** For information on splint: info@splint.org
+** To report a bug: splint-bug@splint.org
 ** For more information: http://www.splint.org
 */
 /*
@@ -33,7 +33,7 @@
 **
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "basic.h"
 # include "randomNumbers.h"
 
@@ -44,19 +44,18 @@ static void
 cstringTable_addEntry (/*@notnull@*/ cstringTable p_h, /*@only@*/ hentry p_e) 
      /*@modifies p_h@*/ ;
 
-static /*@truenull@*/ bool hbucket_isNull (/*@null@*/ hbucket h) 
+static /*@nullwhentrue@*/ bool hbucket_isNull (/*@null@*/ hbucket h) 
 { 
   return (h == hbucket_undefined); 
 }
 
-static hentry hentry_create (/*@keep@*/ cstring key, int val)
+static hentry hentry_create (/*@only@*/ cstring key, int val)
 {
   hentry h = (hentry) dmalloc (sizeof (*h));
 
   h->key = key;
   h->val = val;
-  llassert (val != HBUCKET_DNE); /*@i523 way bogus! */
-
+  llassert (val != HBUCKET_DNE); 
   return (h);
 }
 
@@ -83,7 +82,7 @@ hbucket_unparse (hbucket h)
       
       for (i = 0; i < h->size; i++)
        {
-         s = message ("%q %s:%d", s, h->entries[i]->key, h->entries[i]->val);
+        s = message ("%q %s:%d", s, h->entries[i]->key, h->entries[i]->val);
        }
     }
 
@@ -98,7 +97,7 @@ hbucket_single (/*@only@*/ hentry e)
   h->size = 1;
   h->nspace = HBUCKET_BASESIZE - 1;
   h->entries = (hentry *) dmalloc (HBUCKET_BASESIZE * sizeof (*h->entries));
 h->entries[0] = e;
+ h->entries[0] = e;
   
   return (h);
 }
@@ -119,9 +118,10 @@ hbucket_grow (/*@notnull@*/ hbucket h)
       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);
 
@@ -170,7 +170,7 @@ hbucket_lookup (hbucket h, cstring key)
       
       for (i = 0; i < h->size; i++)
        {
-         if (cstring_equal (h->entries[i]->key, key))
+        if (cstring_equal (h->entries[i]->key, key))
            {
              return h->entries[i]->val;
            }
@@ -185,7 +185,14 @@ void hbucket_free (/*@only@*/ hbucket h)
 {
   if (!hbucket_isNull (h))
     {
-      /*@i32@*/ sfree (h->entries);
+      int i;
+      /* evans 2002-07-12: added this to free entries (splint warning had been suppressed) */
+      for (i = 0; i < h->size; i++)
+       {
+         hentry_free (h->entries[i]);
+       }
+
+      sfree (h->entries);
       sfree (h);
     }
 }
@@ -216,7 +223,7 @@ cstringTable_countCollisions (cstringTable h)
 
   for (i = 0; i < h->size; i++)
     {
-      nc += hbucket_ncollisions (h->buckets[i]);
+     nc += hbucket_ncollisions (h->buckets[i]);
     }
 
   return (nc);
@@ -233,7 +240,7 @@ cstringTable_countEmpty (cstringTable h)
 
   for (i = 0; i < h->size; i++)
     {
-      if (hbucket_isEmpty (h->buckets[i]))
+       if (hbucket_isEmpty (h->buckets[i]))
        {
          nc++;
        }
@@ -281,7 +288,7 @@ cstringTable_create (int size)
   /*@+loopexec@*/
   for (i = 0; i < size; i++)
     {
-      h->buckets[i] = hbucket_undefined;
+       h->buckets[i] = hbucket_undefined;
     }
   /*@-loopexec@*/
   return h;
@@ -296,7 +303,7 @@ cstring cstringTable_unparse (cstringTable h)
     {
       for (i = 0; i < h->size; i++)
        {
-         hbucket hb = h->buckets[i];
+          hbucket hb = h->buckets[i];
          
          if (hb != NULL)
            {
@@ -348,15 +355,15 @@ cstringTable_rehash (/*@notnull@*/ cstringTable h)
   /*@+loopexec@*/
   for (i = 0; i < newsize; i++)
     {
-      h->buckets[i] = hbucket_undefined;
+       h->buckets[i] = hbucket_undefined;
     }
   /*@=loopexec@*/
   
   for (i = 0; i < oldsize; i++)
     {
-      hbucket bucket = oldbuckets[i];
+       hbucket bucket = oldbuckets[i];
 
-      oldbuckets[i] = NULL;
+       oldbuckets[i] = NULL;
 
       if (!hbucket_isNull (bucket))
        {
@@ -364,7 +371,7 @@ cstringTable_rehash (/*@notnull@*/ cstringTable h)
          
          for (j = 0; j < bucket->size; j++)
            {
-             cstringTable_addEntry (h, bucket->entries[j]);
+              cstringTable_addEntry (h, bucket->entries[j]);
            }
          
          /* 
@@ -391,9 +398,9 @@ cstringTable_addEntry (/*@notnull@*/ cstringTable h, /*@only@*/ hentry e)
   ** instead reveals a bug I don't want to deal with right now!
   */
 
-  if (hbucket_isNull (h->buckets[hindex]))
+   if (hbucket_isNull (h->buckets[hindex]))
     {
-      h->buckets[hindex] = hbucket_single (e); 
+       h->buckets[hindex] = hbucket_single (e); 
       h->nentries++;
     }
   else
@@ -429,14 +436,14 @@ cstringTable_insert (cstringTable h, cstring key, int value)
       cstringTable_rehash (h);
     }
   
-  e = hentry_create (key, value);
   hindex = cstringTable_hashValue (h, key);
+  e = hentry_create (key, value);
 
-  hb = h->buckets[hindex];
+   hb = h->buckets[hindex];
   
   if (hbucket_isNull (hb))
     {
-      h->buckets[hindex] = hbucket_single (e);
+       h->buckets[hindex] = hbucket_single (e);
     }
   else
     {
@@ -470,9 +477,9 @@ cstringTable_update (cstringTable h, cstring key, int newval)
       
       for (i = 0; i < hb->size; i++)
        {
-         if (cstring_equal (hb->entries[i]->key, key))
+          if (cstring_equal (hb->entries[i]->key, key))
            {
-             hb->entries[i]->val = newval;
+                  hb->entries[i]->val = newval;
              return;
            }
        }
@@ -490,7 +497,7 @@ cstringTable_replaceKey (cstringTable h, cstring oldkey, /*@only@*/ cstring newk
 {
   hbucket hb;
   llassert (cstringTable_isDefined (h));
-
+  
   hb = cstringTable_hash (h, oldkey);
   llassert (cstring_equal (oldkey, newkey));
 
@@ -500,7 +507,7 @@ cstringTable_replaceKey (cstringTable h, cstring oldkey, /*@only@*/ cstring newk
       
       for (i = 0; i < hb->size; i++)
        {
-         if (cstring_equal (hb->entries[i]->key, oldkey))
+          if (cstring_equal (hb->entries[i]->key, oldkey))
            {
              hb->entries[i]->key = newkey;
              return;
@@ -525,11 +532,11 @@ cstringTable_remove (cstringTable h, cstring key)
       
       for (i = 0; i < hb->size; i++)
        {
-         if (cstring_equal (hb->entries[i]->key, key))
+          if (cstring_equal (hb->entries[i]->key, key))
            {
              if (i < hb->size - 1)
                {
-                 hb->entries[i] = hb->entries[hb->size - 1];
+                                 hb->entries[i] = hb->entries[hb->size - 1];
                }
              
              hb->size--;
This page took 0.046304 seconds and 4 git commands to generate.