/*
** 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
*/
/*
You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */
-# include "lclintMacros.nf"
-# include "llbasic.h"
+# include "splintMacros.nf"
+# include "basic.h"
# include <string.h>
# include "cpplib.h"
# include "cpphash.h"
** From: "N.Komazaki" <koma@focs.sei.co.jp>
*/
- /*! why doesn't lclint report an error for this? */
+ /*! why doesn't splint report an error for this? */
nd->args.argnames = mstring_createEmpty ();
}
}
computed a step at a time, elsewhere */
int
-cpphash_hashCode (const char *name, int len, int hashsize)
+cpphash_hashCode (const char *name, size_t len, int hashsize)
{
unsigned int r = 0;
** Find the most recent hash node for name name (ending with first
** non-identifier char) cpphash_installed by install
**
-** If LEN is >= 0, it is the length of the name.
+** If len is >= 0, it is the length of the name.
** Otherwise, compute the length by scanning the entire name.
**
-** If HASH is >= 0, it is the precomputed hash code.
+** If hash is >= 0, it is the precomputed hash code.
** Otherwise, compute the hash code.
*/
if (hash < 0)
{
- hash = cpphash_hashCode (name, len, CPP_HASHSIZE);
+ hash = cpphash_hashCode (name, size_fromInt (len), CPP_HASHSIZE);
}
bucket = hashtab[hash];
while (bucket != NULL)
{
- if (bucket->length == len &&
- cstring_equalLen (bucket->name, cstring_fromChars (name), len))
+ if (bucket->length == size_fromInt (len) &&
+ cstring_equalLen (bucket->name, cstring_fromChars (name), size_fromInt (len)))
{
return bucket;
}
/* make sure that the bucket chain header that
the deleted guy was on points to the right thing afterwards. */
+
+ llassert (hp != NULL);
+ llassert (hp->bucket_hdr != NULL);
+
if (hp == *hp->bucket_hdr) {
*hp->bucket_hdr = hp->next;
}
int ivalue, char *value, int hash)
{
hashNode hp;
- int i, bucket;
+ int bucket;
char *p;
DPRINTF (("Install: %s / %d", name, len));
if (hash < 0)
{
- hash = cpphash_hashCode (name, len, CPP_HASHSIZE);
+ hash = cpphash_hashCode (name, size_fromInt (len), CPP_HASHSIZE);
}
- i = sizeof (*hp) + len + 1;
-
hp = (hashNode) dmalloc (sizeof (*hp));
bucket = hash;
hp->bucket_hdr = &hashtab[bucket];
hashtab[bucket] = hp;
hp->type = type;
- hp->length = len;
+ hp->length = size_fromInt (len);
if (hp->type == T_CONST)
{
hp->value.cpval = value;
}
- hp->name = cstring_clip (cstring_fromCharsNew (name), len);
+ hp->name = cstring_clip (cstring_fromCharsNew (name), size_fromInt (len));
DPRINTF (("Name: *%s*", hp->name));
/*@-mustfree@*/ /*@-uniondef@*/ /*@-compdef@*/ /*@-compmempass@*/
/*@=mustfree@*/ /*@=uniondef@*/ /*@=compdef@*/ /*@=compmempass@*/
}
-hashNode cpphash_installMacro (char *name, int len,
+hashNode cpphash_installMacro (char *name, size_t len,
struct definition *defn, int hash)
{
DPRINTF (("install macro: %s", name));
- return cpphash_install (name, len, T_MACRO, 0, (char *) defn, hash);
+ return cpphash_install (name, size_toInt (len), T_MACRO, 0, (char *) defn, hash);
}
void