summaryrefslogtreecommitdiff
path: root/hax_table.h
diff options
context:
space:
mode:
Diffstat (limited to 'hax_table.h')
-rw-r--r--hax_table.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/hax_table.h b/hax_table.h
index 90cbbdb..5db58ee 100644
--- a/hax_table.h
+++ b/hax_table.h
@@ -30,9 +30,15 @@
#include "hax_string.h"
+// because C and function pointers vs non-function pointers
+union table_ptr {
+ void *data;
+ void (*function)(void);
+};
+
struct table_index {
struct string name;
- void *ptr;
+ union table_ptr ptr;
};
struct table {
@@ -40,12 +46,13 @@ struct table {
size_t len;
};
-extern int set_table_index(struct table *tbl, struct string name, void *ptr);
-extern void * get_table_index(struct table tbl, struct string name);
+extern int set_table_index(struct table *tbl, struct string name, union table_ptr ptr);
+extern union table_ptr get_table_index(struct table tbl, struct string name, char *exists);
extern char has_table_index(struct table tbl, struct string name);
-extern void * remove_table_index(struct table *tbl, struct string name); // returns same as get_table_index
+extern void remove_table_index(struct table *tbl, struct string name);
+extern union table_ptr get_and_remove_table_index(struct table *tbl, struct string name, char *exists); // returns same as get_table_index
extern void clear_table(struct table *tbl);
extern size_t get_table_offset(struct table tbl, struct string name, char *exists);
// Longest index that <name> starts with
-extern void * get_table_prefix(struct table tbl, struct string name);
+extern union table_ptr get_table_prefix(struct table tbl, struct string name, char *exists);