summaryrefslogtreecommitdiffstats
path: root/gcc/cpphash.c
diff options
context:
space:
mode:
authorzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2000-05-01 18:20:10 +0000
committerzack <zack@138bc75d-0d04-0410-961f-82ee72b054a4>2000-05-01 18:20:10 +0000
commit3ba8b4970fccde027893c42805f2aee3a1722e8b (patch)
treef86e627be1bd97d95d7ce2354cf47e7860868588 /gcc/cpphash.c
parent6d20039dbfdd928f289e194e0c4220e46c550147 (diff)
downloadppe42-gcc-3ba8b4970fccde027893c42805f2aee3a1722e8b.tar.gz
ppe42-gcc-3ba8b4970fccde027893c42805f2aee3a1722e8b.zip
* cpphash.c (_cpp_make_hashnode): Rename make_HASHNODE, now
static. Allocate the hashnode and its string in the same block of memory. (del_HASHNODE): Don't free h->name. (_cpp_lookup): If there is no entry for this string, create one, of type T_VOID. (_cpp_lookup_slot): Delete. * cpphash.h: Update prototypes. * cpplex.c (maybe_macroexpand): Check for hp->type == T_VOID, not hp == NULL. * cpplib.c (do_define, do_undef, do_pragma_poison, do_assert, do_unassert, cpp_defined): Use _cpp_lookup. Don't create a node here, just fill in the value field properly. "Delete" entries by setting the value field to T_VOID. Check for hp->type == T_VOID, not hp == NULL. * Makefile.in (cpplib.o): Don't depend on $(HASHTAB_H). * cpperror.c, cppexp.c, cpplex.c, cpplib.c: Don't include hashtab.h. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33581 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpphash.c')
-rw-r--r--gcc/cpphash.c46
1 files changed, 17 insertions, 29 deletions
diff --git a/gcc/cpphash.c b/gcc/cpphash.c
index 4eb2d9d33e6..97ca109cbdd 100644
--- a/gcc/cpphash.c
+++ b/gcc/cpphash.c
@@ -103,6 +103,9 @@ struct funct_defn
static unsigned int hash_HASHNODE PARAMS ((const void *));
static int eq_HASHNODE PARAMS ((const void *, const void *));
static void del_HASHNODE PARAMS ((void *));
+static HASHNODE *make_HASHNODE PARAMS ((const U_CHAR *, size_t,
+ enum node_type, unsigned int));
+
static void dump_funlike_macro PARAMS ((cpp_reader *,
const struct funct_defn *));
static int dump_hash_helper PARAMS ((void **, void *));
@@ -234,22 +237,21 @@ del_HASHNODE (x)
HASHNODE *h = (HASHNODE *)x;
_cpp_free_definition (h);
- free ((void *) h->name);
free (h);
}
/* Allocate and initialize a HASHNODE structure.
Caller must fill in the value field. */
-HASHNODE *
-_cpp_make_hashnode (name, len, type, hash)
+static HASHNODE *
+make_HASHNODE (name, len, type, hash)
const U_CHAR *name;
size_t len;
enum node_type type;
unsigned int hash;
{
- HASHNODE *hp = (HASHNODE *) xmalloc (sizeof (HASHNODE));
- U_CHAR *p = xmalloc (len + 1);
+ HASHNODE *hp = (HASHNODE *) xmalloc (sizeof (HASHNODE) + len + 1);
+ U_CHAR *p = (U_CHAR *)hp + sizeof (HASHNODE);
hp->type = type;
hp->length = len;
@@ -271,37 +273,23 @@ _cpp_lookup (pfile, name, len)
const U_CHAR *name;
int len;
{
- const U_CHAR *bp;
HASHNODE dummy;
+ HASHNODE *new, **slot;
dummy.name = name;
dummy.length = len;
dummy.hash = _cpp_calc_hash (name, len);
- return (HASHNODE *) htab_find_with_hash (pfile->hashtab,
- (void *)&dummy, dummy.hash);
-}
-
-/* Find the hashtable slot for name "name". Used to insert or delete. */
-
-HASHNODE **
-_cpp_lookup_slot (pfile, name, len, insert, hash)
- cpp_reader *pfile;
- const U_CHAR *name;
- int len;
- enum insert_option insert;
- unsigned int hash;
-{
- const U_CHAR *bp;
- HASHNODE dummy;
-
- dummy.name = name;
- dummy.length = len;
- dummy.hash = hash;
+ slot = (HASHNODE **)
+ htab_find_slot_with_hash (pfile->hashtab, (void *)&dummy,
+ dummy.hash, INSERT);
+ if (*slot)
+ return *slot;
- return (HASHNODE **) htab_find_slot_with_hash (pfile->hashtab,
- (void *) &dummy,
- dummy.hash, insert);
+ new = make_HASHNODE (name, len, T_VOID, dummy.hash);
+ new->value.cpval = NULL;
+ *slot = new;
+ return new;
}
/* Init the hash table. In here so it can see the hash and eq functions. */
OpenPOWER on IntegriCloud