/[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.6 by gary, Tue May 28 21:30:24 2002 UTC revision 1.7 by gary, Tue May 28 21:46:37 2002 UTC
# Line 311  m4_hash_length (m4_hash *hash) Line 311  m4_hash_length (m4_hash *hash)
311    return M4_HASH_LENGTH (hash);    return M4_HASH_LENGTH (hash);
312  }  }
313    
314    /* Force the number of buckets to be the given value.  You probably ought
315       not to be using this function once the table has been in use, since
316       the maximum density algorithm will grow the number of buckets back to
317       what was there before if you try to shrink the table.  It is useful
318       to set a smaller or larger initial size if you know in advance what
319       order of magnitude of entries will be in the table.  Be aware that
320       the efficiency of the lookup and grow features require that the size
321       always be 1 less than a power of 2.  */
322    void
323    m4_hash_resize (m4_hash *hash, size_t size)
324    {
325      m4_hash_node **original_buckets;
326      size_t original_size;
327    
328      assert (hash);
329    
330      original_size         = M4_HASH_SIZE (hash);
331      original_buckets      = M4_HASH_BUCKETS (hash);
332    
333      M4_HASH_SIZE (hash)   = size;
334      M4_HASH_BUCKETS (hash)= XCALLOC (m4_hash_node *, size);
335    
336      {
337        size_t i;
338        for (i = 0; i < original_size; ++i)
339          if (original_buckets[i])
340            m4_hash_bucket_insert (hash, original_buckets[i]);
341      }
342    
343      XFREE (original_buckets);
344    }
345    
346  /* If the node density breaks the threshold, increase the size of  /* If the node density breaks the threshold, increase the size of
347     HASH and repopulate with the original nodes.  */     HASH and repopulate with the original nodes.  */
348  void  void

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

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