for (i = 0; i < 100; i++) { value = (char*) acl_mystrdup("value"); snprintf(key, sizeof(key), "key:%d", i); (void) acl_htable_enter(table, key, value); }
#ifndef ACL_HTABLE_INCLUDE_H
#define ACL_HTABLE_INCLUDE_H
#ifdef __cplusplus
extern "C" {
#endif
#include "../thread/acl_thread.h"
};
union {
};
#define ACL_HTABLE_FLAG_KEY_REUSE (1 << 0)
#define ACL_HTABLE_FLAG_USE_LOCK (1 << 1)
#define ACL_HTABLE_FLAG_MSLOOK (1 << 2)
#define ACL_HTABLE_FLAG_KEY_LOWER (1 << 3)
#define ACL_HTABLE_CTL_END 0
#define ACL_HTABLE_CTL_RWLOCK 1
#define ACL_HTABLE_CTL_HASH_FN 2
#define ACL_HTABLE_STAT_OK 0
#define ACL_HTABLE_STAT_INVAL 1
#define ACL_HTABLE_STAT_DUPLEX_KEY 2
const char *key, void *value);
void (*callback)(void *value, void *arg), void *arg);
void (*free_fn) (void *));
#define acl_htable_delete_r acl_htable_delete
void (*free_fn) (void *));
#define acl_htable_reset_r acl_htable_reset
#define acl_htable_walk_r acl_htable_walk
#define acl_htable_stat_r acl_htable_stat
#define ACL_HTABLE_ITER_KEY(iter) ((iter).ptr->key.c_key)
#define acl_htable_iter_key ACL_HTABLE_ITER_KEY
#define ACL_HTABLE_ITER_VALUE(iter) ((iter).ptr->value)
#define acl_htable_iter_value ACL_HTABLE_ITER_VALUE
#if 0
#define ACL_HTABLE_FOREACH(iter, table_ptr) \
if (table_ptr) \
for((iter).size = acl_htable_size((table_ptr)), (iter).i = 0, \
(iter).h = acl_htable_data((table_ptr)); (iter).i < (iter).size; (iter).i++) \
for ((iter).ptr = *(iter).h++; (iter).ptr; (iter).ptr = (iter).ptr->next)
#define ACL_HTABLE_FOREACH_REVERSE(iter, table_ptr) \
if (table_ptr) \
for((iter).size = acl_htable_size((table_ptr)), (iter).i = (iter).size - 1, \
(iter).h = acl_htable_data((table_ptr)) + (iter).i; (iter).i >= 0; (iter).i--) \
for ((iter).ptr = *(iter).h--; (iter).ptr; (iter).ptr = (iter).ptr->next)
#else
#define ACL_HTABLE_FOREACH(iter, table_ptr) \
if (table_ptr) \
for((void) acl_htable_iter_head((table_ptr), &iter); \
(iter).ptr; \
(void) acl_htable_iter_next(&iter))
#define ACL_HTABLE_FOREACH_REVERSE(iter, table_ptr) \
if (table_ptr) \
for((void) acl_htable_iter_tail((table_ptr), &iter); \
(iter).ptr; \
(void) acl_htable_iter_prev(&iter))
#endif
#define acl_htable_foreach ACL_HTABLE_FOREACH
#define acl_htable_foreach_reverse ACL_HTABLE_FOREACH_REVERSE
#ifdef __cplusplus
}
#endif
#endif