This repository has been archived on 2023-11-05. You can view files and clone it, but cannot push or open issues or pull requests.
wrt/utils/tinymap.h
Paul Pan a471519ff7 feat: basic dl_call support
1. add basic dl_call support
2. re-organize code structure
3. fix `wasm_runtime_call_wasm` error handler
4. update examples
2023-02-11 14:33:45 +08:00

33 lines
555 B
C

#ifndef WRT_TINYMAP_H
#define WRT_TINYMAP_H
#include <stdbool.h>
#ifndef BUK_SIZE
#define BUK_SIZE 8
#endif
#ifndef NOD_SIZE
#define NOD_SIZE 32
#endif
typedef struct {
int key;
void *value;
unsigned next;
} MapNode;
typedef struct {
MapNode node[NOD_SIZE + 1];
unsigned head[BUK_SIZE];
unsigned count;
} Map;
void map_init(Map *map);
void *map_get(Map *map, int key);
bool map_set(Map *map, int key, void *value);
void map_delete(Map *map, int key);
void map_compact(Map *map);
#endif // WRT_TINYMAP_H