MCPcopy Index your code
hub / github.com/RsyncProject/rsync / hashtable_create

Function hashtable_create

hashtable.c:24–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22#define HASH_LOAD_LIMIT(size) ((size)*3/4)
23
24struct hashtable *hashtable_create(int size, int key64)
25{
26 int req = size;
27 struct hashtable *tbl;
28 int node_size = key64 ? sizeof (struct ht_int64_node)
29 : sizeof (struct ht_int32_node);
30
31 /* Pick a power of 2 that can hold the requested size. */
32 if (size & (size-1) || size < 16) {
33 size = 16;
34 while (size < req)
35 size *= 2;
36 }
37
38 tbl = new(struct hashtable);
39 tbl->nodes = new_array0(char, size * node_size);
40 tbl->size = size;
41 tbl->entries = 0;
42 tbl->node_size = node_size;
43 tbl->key64 = key64 ? 1 : 0;
44
45 if (DEBUG_GTE(HASH, 1)) {
46 char buf[32];
47 if (req != size)
48 snprintf(buf, sizeof buf, "req: %d, ", req);
49 else
50 *buf = '\0';
51 rprintf(FINFO, "[%s] created hashtable %lx (%ssize: %d, keys: %d-bit)\n",
52 who_am_i(), (long)tbl, buf, size, key64 ? 64 : 32);
53 }
54
55 return tbl;
56}
57
58void hashtable_destroy(struct hashtable *tbl)
59{

Callers 4

init_hard_linksFunction · 0.85
idev_findFunction · 0.85
delete_in_dirFunction · 0.85
rsync_xal_storeFunction · 0.85

Calls 2

rprintfFunction · 0.70
who_am_iFunction · 0.70

Tested by

no test coverage detected