File: ghash_rehash.c

package info (click to toggle)
bglibs 2.04%2Bdfsg-8
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,468 kB
  • sloc: ansic: 15,821; perl: 674; sh: 63; makefile: 29
file content (16 lines) | stat: -rw-r--r-- 438 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdlib.h>
#include <string.h>

#include "ghash.h"

/** Regenerate all the hash values in a \c ghash table and then rebuild
 * it. Use this function when any of the keys change value. */
int ghash_rehash(struct ghash* d)
{
  unsigned i;
  void** entry;
  for (i = 0, entry = d->table; i < d->size; ++i, ++entry)
    if (*entry)
      ghash_entry_hash(*entry) = d->hashfn(ghash_entry_keyptr(*entry));
  return ghash_rebuild(d);
}