/[bison]/bison/lib/hash.c
ViewVC logotype

Diff of /bison/lib/hash.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by ra, Sat Aug 25 14:15:11 2001 UTC revision 1.4 by akim, Mon Dec 10 09:05:47 2001 UTC
# Line 1  Line 1 
1  /* hash.c -- hash table maintenance  /* hash.c -- hash table maintenance
2     Copyright (C) 1995 Free Software Foundation, Inc.     Copyright 1995, 2001  Free Software Foundation, Inc.
3     Written by Greg McGary <gkm@gnu.ai.mit.edu>     Written by Greg McGary <gkm@gnu.ai.mit.edu>
4    
5     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
# Line 120  hash_find_item (struct hash_table* ht, v Line 120  hash_find_item (struct hash_table* ht, v
120    return ((HASH_VACANT (*slot)) ? 0 : *slot);    return ((HASH_VACANT (*slot)) ? 0 : *slot);
121  }  }
122    
123  void *  const void *
124  hash_insert (struct hash_table* ht, void *item)  hash_insert (struct hash_table* ht, void *item)
125  {  {
126    void **slot = hash_find_slot (ht, item);    void **slot = hash_find_slot (ht, item);
127    return hash_insert_at (ht, item, slot);    return hash_insert_at (ht, item, slot);
128  }  }
129    
130  void *  const void *
131  hash_insert_at (struct hash_table* ht, void *item, void const *slot)  hash_insert_at (struct hash_table* ht, void *item, void const *slot)
132  {  {
133    void *old_item = *(void **) slot;    const void *old_item = *(const void **) slot;
134    if (HASH_VACANT (old_item))    if (HASH_VACANT (old_item))
135      {      {
136        ht->ht_fill++;        ht->ht_fill++;
# Line 142  hash_insert_at (struct hash_table* ht, v Line 142  hash_insert_at (struct hash_table* ht, v
142    return old_item;    return old_item;
143  }  }
144    
145  void *  const void *
146  hash_delete (struct hash_table* ht, void const *item)  hash_delete (struct hash_table* ht, void const *item)
147  {  {
148    void **slot = hash_find_slot (ht, item);    void **slot = hash_find_slot (ht, item);
149    return hash_delete_at (ht, slot);    return hash_delete_at (ht, slot);
150  }  }
151    
152  void *  const void *
153  hash_delete_at (struct hash_table* ht, void const *slot)  hash_delete_at (struct hash_table* ht, void const *slot)
154  {  {
155    void *item = *(void **) slot;    const void *item = *(const void **) slot;
156    if (!HASH_VACANT (item))    if (!HASH_VACANT (item))
157      {      {
158        *(void const **) slot = hash_deleted_item;        *(void const **) slot = hash_deleted_item;

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26