]> andersk Git - splint.git/blobdiff - src/genericTable.c
Fixed all /*@i...@*/ tags (except 1).
[splint.git] / src / genericTable.c
index e2c00d770fdabf28d42b61c332418431ba883e52..5e1b2a3de09869a92fd6bc43ab1dccc1bf7c3abb 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ** Splint - annotation-assisted static program checker
-** Copyright (C) 1994-2002 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
 */
 /*
@@ -28,7 +28,7 @@
 ** We sacrific type checking here for code reuse.
 */
 
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
 # include "basic.h"
 # include "randomNumbers.h"
 
@@ -53,6 +53,15 @@ ghentry_create (/*@keep@*/ cstring key, /*@keep@*/ void *val)
   return (h);
 }
 
+static void
+ghentry_free (/*@only@*/ ghentry ghe)
+{
+  cstring_free (ghe->key);
+  /* can't free val contents */
+  sfree (ghe->val);
+  sfree (ghe);
+}
+
 static bool
 ghbucket_isEmpty (ghbucket h)
 {
@@ -95,7 +104,7 @@ static ghbucket ghbucket_single (/*@keep@*/ ghentry e)
   h->size = 1;
   h->nspace = GHBUCKET_BASESIZE - 1;
   h->entries = (ghentry *) dmalloc (GHBUCKET_BASESIZE * sizeof (*h->entries));
-  /*@i23@*/ h->entries[0] = e;
+  h->entries[0] = e;
   
   return (h);
 }
@@ -116,9 +125,10 @@ ghbucket_grow (/*@notnull@*/ ghbucket h)
       newentries[i] = h->entries[i]; 
     }
   
-  /*@i32@*/ sfree (h->entries);
+  sfree (h->entries);
   h->entries = newentries; 
-/*@i32@*/ }
+  /*@-compmempass@*/
+} /*@=compmempass*/ /* Spurious warnings reported for h->entries */ 
 
 static /*@null@*/ /*@exposed@*/ void *ghbucket_lookup (ghbucket p_h, cstring p_key);
 
@@ -143,7 +153,7 @@ ghbucket_add (/*@notnull@*/ ghbucket h, /*@only@*/ ghentry e)
     h->entries[h->size] = e;
     h->size++;
     h->nspace--;
-/*@i23@*/ }
+}
 
 static int
 ghbucket_ncollisions (ghbucket h)
@@ -178,7 +188,14 @@ void ghbucket_free (/*@only@*/ ghbucket h)
 {
   if (!ghbucket_isNull (h))
     {
-      /*@i32@*/ sfree (h->entries);
+      int i;
+
+      for (i = 0; i < h->size; i++)  
+       {
+         ghentry_free (h->entries[i]);
+       }
+
+      sfree (h->entries);
       sfree (h);
     }
 }
@@ -323,7 +340,7 @@ genericTable_stats (genericTable h)
 }
 
 static void
-genericTable_addEntry (/*@notnull@*/ genericTable h, /*@keep@*/ ghentry e)
+genericTable_addEntry (/*@notnull@*/ genericTable h, /*@only@*/ ghentry e)
 {
   unsigned int hindex = genericTable_hashValue (h, e->key);
   /*
@@ -340,8 +357,8 @@ genericTable_addEntry (/*@notnull@*/ genericTable h, /*@keep@*/ ghentry e)
     }
   else
     {
-      /*@i23@*/ ghbucket_add (h->buckets[hindex], e);
-      /*@i23@*/ }
+      ghbucket_add (h->buckets[hindex], e);
+    }
 }
 
 void
@@ -407,13 +424,13 @@ genericTable_insert (genericTable h, cstring key, void *value)
   
   if (ghbucket_isNull (hb))
       {
-         /*@i23@*/ h->buckets[hindex] = ghbucket_single (e);
+       h->buckets[hindex] = ghbucket_single (e);
       }
   else
       {
-         ghbucket_add (hb, e);
-         /*@i23@*/ }
-/*@i23@*/ }
+       ghbucket_add (hb, e);
+      }
+}
 
 /*@null@*/ /*@exposed@*/ void *
 genericTable_lookup (genericTable h, cstring key)
This page took 0.065217 seconds and 4 git commands to generate.