/*
** 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
** 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
*/
/*
**
*/
-# include "lclintMacros.nf"
+# include "splintMacros.nf"
# include "basic.h"
# include "randomNumbers.h"
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));
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);
}
}
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);
}
for (i = 0; i < h->size; i++)
{
- newentries[i] = h->entries[i];
+ newentries[i] = h->entries[i];
}
/*@i32@*/ sfree (h->entries);
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;
}
{
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);
}
}
for (i = 0; i < h->size; i++)
{
- nc += hbucket_ncollisions (h->buckets[i]);
+ nc += hbucket_ncollisions (h->buckets[i]);
}
return (nc);
for (i = 0; i < h->size; i++)
{
- if (hbucket_isEmpty (h->buckets[i]))
+ if (hbucket_isEmpty (h->buckets[i]))
{
nc++;
}
/*@+loopexec@*/
for (i = 0; i < size; i++)
{
- h->buckets[i] = hbucket_undefined;
+ h->buckets[i] = hbucket_undefined;
}
/*@-loopexec@*/
return h;
{
for (i = 0; i < h->size; i++)
{
- hbucket hb = h->buckets[i];
+ hbucket hb = h->buckets[i];
if (hb != NULL)
{
/*@+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))
{
for (j = 0; j < bucket->size; j++)
{
- cstringTable_addEntry (h, bucket->entries[j]);
+ cstringTable_addEntry (h, bucket->entries[j]);
}
/*
** 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
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
{
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;
}
}
{
hbucket hb;
llassert (cstringTable_isDefined (h));
-
+
hb = cstringTable_hash (h, oldkey);
llassert (cstring_equal (oldkey, newkey));
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;
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--;