Use stylesheet transformations to output HTML, for example
This commit is contained in:
36
src/hash.h
Normal file
36
src/hash.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef _HASH_H
|
||||
#define _HASH_H
|
||||
|
||||
#include "queue.h"
|
||||
|
||||
#define HASH_ENTRIES 1024
|
||||
uint32_t HASH_KEY(char *);
|
||||
|
||||
#define DEFINE_HASH(T, N) \
|
||||
typedef struct { \
|
||||
char* key; \
|
||||
T data; \
|
||||
} N##Entry; \
|
||||
DEFINE_QUEUE(N##Entry, N##CollisionQueue) \
|
||||
typedef N##CollisionQueue N[HASH_ENTRIES]; \
|
||||
const N##Entry* N##Find(N tbl, const char* key) { \
|
||||
uint32_t track = HASH_KEY(key); \
|
||||
FOREACH_QUEUE(N##CollisionQueue, tbl[track], iter) { \
|
||||
if (strcmp(key, iter->data.key) == 0) { \
|
||||
return &iter->data; \
|
||||
} \
|
||||
} \
|
||||
return NULL; \
|
||||
}
|
||||
|
||||
#define INIT_HASH(T, H) { \
|
||||
int i; \
|
||||
for (i = 0; i < HASH_ENTRIES; i++) { \
|
||||
(H)[i].length = 0; \
|
||||
(H)[i].tail = (H)[i].head = NULL; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* !def _HASH_H */
|
||||
Reference in New Issue
Block a user