预定义代码:
struct hashtable {
void *nodes;
int32 size, entries;
uint32 node_size;
int key64;
};
struct ht_int32_node {
void *data;
int32 key;
};
struct ht_int64_node {
void *data;
int64 key;
};
#define HT_NODE(tbl, bkts, i) ((void*)((char*)(bkts) + (i)*(tbl)->node_size))
#define HT_KEY(node, k64) ((k64)? ((struct ht_int64_node*)(node))->key \
: (int64)((struct ht_int32_node*)(node))->key)
hashtable.c:
/*
* Routines to provide a memory-efficient hashtable.
*
* Copyright (C) 2007-2009 Wayne Davison
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This progr