/[m4]/m4/m4/hash.c
ViewVC logotype

Diff of /m4/m4/hash.c

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

revision 1.14 by gary, Tue Oct 7 14:10:12 2003 UTC revision 1.15 by gary, Wed Oct 8 14:46:12 2003 UTC
# Line 94  m4_hash_new (size_t size, m4_hash_hash_f Line 94  m4_hash_new (size_t size, m4_hash_hash_f
94    if (size == 0)    if (size == 0)
95      size = M4_HASH_DEFAULT_SIZE;      size = M4_HASH_DEFAULT_SIZE;
96    
97    hash                  = XMALLOC (m4_hash, 1);    hash                  = xmalloc (sizeof *hash);
98    HASH_SIZE (hash)      = size;    HASH_SIZE (hash)      = size;
99    HASH_LENGTH (hash)    = 0;    HASH_LENGTH (hash)    = 0;
100    HASH_BUCKETS (hash)   = XCALLOC (hash_node *, size);    HASH_BUCKETS (hash)   = xcalloc (size, sizeof HASH_BUCKETS (hash));
101    HASH_HASH_FUNC (hash) = hash_func;    HASH_HASH_FUNC (hash) = hash_func;
102    HASH_CMP_FUNC (hash)  = cmp_func;    HASH_CMP_FUNC (hash)  = cmp_func;
103    
# Line 178  node_new (const void *key, void *value) Line 178  node_new (const void *key, void *value)
178      }      }
179    else    else
180      {      {
181        node      = XMALLOC (hash_node, 1);        node      = xmalloc (sizeof *node);
182      }      }
183    
184    assert (node);    assert (node);
# Line 345  m4_hash_resize (m4_hash *hash, size_t si Line 345  m4_hash_resize (m4_hash *hash, size_t si
345    original_buckets      = HASH_BUCKETS (hash);    original_buckets      = HASH_BUCKETS (hash);
346    
347    HASH_SIZE (hash)      = size;    HASH_SIZE (hash)      = size;
348    HASH_BUCKETS (hash)= XCALLOC (hash_node *, size);    HASH_BUCKETS (hash)   = xcalloc (size, sizeof HASH_BUCKETS (hash));
349    
350    {    {
351      size_t i;      size_t i;
# Line 376  maybe_grow (m4_hash *hash) Line 376  maybe_grow (m4_hash *hash)
376    
377        /* HASH sizes are always 1 less than a power of 2.  */        /* HASH sizes are always 1 less than a power of 2.  */
378        HASH_SIZE (hash)    = (2* (1+ original_size)) -1;        HASH_SIZE (hash)    = (2* (1+ original_size)) -1;
379        HASH_BUCKETS (hash) = XCALLOC (hash_node *, hash->size);        HASH_BUCKETS (hash) = xcalloc (hash->size, sizeof HASH_BUCKETS (hash));
380    
381        {        {
382          size_t i;          size_t i;
# Line 447  m4_get_hash_iterator_next (const m4_hash Line 447  m4_get_hash_iterator_next (const m4_hash
447    /* On the first iteration, allocate an iterator.  */    /* On the first iteration, allocate an iterator.  */
448    if (!place)    if (!place)
449      {      {
450        place = XCALLOC (m4_hash_iterator, 1);        place = xcalloc (1, sizeof *place);
451        ITERATOR_HASH (place) = hash;        ITERATOR_HASH (place) = hash;
452      }      }
453    

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

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