The htab functions find_str and add_str have been renamed to include _ref in the places they previously noted _str. These are intended to manage an htab containing references to any data; string or not. The htab_find function has been divided up. htab_find_core now handles actually finding the correct node. htab_find and htab_find_ref are just outward facing functions for retrieving a specific kind of data from the node, depending on what the htab is used for.
30 lines
645 B
C
30 lines
645 B
C
#ifndef TVM_HTAB_H_
|
|
#define TVM_HTAB_H_
|
|
|
|
#define KEY_LENGTH 64
|
|
#define HTAB_SIZE 4096
|
|
|
|
typedef struct tvm_htab_node_s
|
|
{
|
|
char *key;
|
|
int value;
|
|
void *valptr;
|
|
struct tvm_htab_node_s *next;
|
|
} tvm_htab_node_t;
|
|
|
|
typedef struct tvm_htab_s
|
|
{
|
|
unsigned int num_nodes;
|
|
unsigned int size;
|
|
tvm_htab_node_t **nodes;
|
|
} tvm_htab_t;
|
|
|
|
tvm_htab_t* htab_create();
|
|
void htab_destroy(tvm_htab_t *htab);
|
|
|
|
int htab_add(tvm_htab_t *htab, const char *key, int value);
|
|
int htab_add_ref(tvm_htab_t *htab, const char *key, const void *valptr, int len);
|
|
int htab_find(tvm_htab_t *htab, const char *key);
|
|
char *htab_find_ref(tvm_htab_t *htab, const char *key);
|
|
|
|
#endif
|