Mercurial > repos > blastem
comparison tern.h @ 1326:071e761bcdcf
Fix a deficiency in the way types were handled in my ternary tree. Fixes in which some paths that were constructed from a template with variables would sometimes get an extra garbage character thrown in
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 21 Apr 2017 23:35:32 -0700 |
parents | 72ea3885e7b5 |
children | e890971f3757 |
comparison
equal
deleted
inserted
replaced
1325:58bfbed6cdb5 | 1326:071e761bcdcf |
---|---|
21 struct tern_node *next; | 21 struct tern_node *next; |
22 tern_val value; | 22 tern_val value; |
23 } straight; | 23 } straight; |
24 struct tern_node *right; | 24 struct tern_node *right; |
25 char el; | 25 char el; |
26 uint8_t valtype; | |
26 } tern_node; | 27 } tern_node; |
27 | 28 |
28 typedef void (*iter_fun)(char *key, tern_val val, void *data); | 29 enum { |
30 TVAL_NONE=0, | |
31 TVAL_INT, | |
32 TVAL_PTR, | |
33 TVAL_NODE | |
34 }; | |
29 | 35 |
30 tern_node * tern_insert(tern_node * head, char const * key, tern_val value); | 36 typedef void (*iter_fun)(char *key, tern_val val, uint8_t valtype, void *data); |
31 int tern_find(tern_node * head, char const * key, tern_val *ret); | 37 |
38 tern_node * tern_insert(tern_node * head, char const * key, tern_val value, uint8_t valtype); | |
39 uint8_t tern_find(tern_node * head, char const * key, tern_val *ret); | |
32 tern_node * tern_find_prefix(tern_node * head, char const * key); | 40 tern_node * tern_find_prefix(tern_node * head, char const * key); |
33 intptr_t tern_find_int(tern_node * head, char const * key, intptr_t def); | 41 intptr_t tern_find_int(tern_node * head, char const * key, intptr_t def); |
34 tern_node * tern_insert_int(tern_node * head, char const * key, intptr_t value); | 42 tern_node * tern_insert_int(tern_node * head, char const * key, intptr_t value); |
35 void * tern_find_ptr_default(tern_node * head, char const * key, void * def); | 43 void * tern_find_ptr_default(tern_node * head, char const * key, void * def); |
36 void * tern_find_ptr(tern_node * head, char const * key); | 44 void * tern_find_ptr(tern_node * head, char const * key); |
37 tern_val tern_find_path_default(tern_node *head, char const *key, tern_val def); | 45 tern_node *tern_find_node(tern_node *head, char const *key); |
38 tern_val tern_find_path(tern_node *head, char const *key); | 46 tern_val tern_find_path_default(tern_node *head, char const *key, tern_val def, uint8_t req_valtype); |
47 tern_val tern_find_path(tern_node *head, char const *key, uint8_t valtype); | |
39 tern_node * tern_insert_ptr(tern_node * head, char const * key, void * value); | 48 tern_node * tern_insert_ptr(tern_node * head, char const * key, void * value); |
40 tern_node * tern_insert_node(tern_node *head, char const *key, tern_node *value); | 49 tern_node * tern_insert_node(tern_node *head, char const *key, tern_node *value); |
41 uint32_t tern_count(tern_node *head); | 50 uint32_t tern_count(tern_node *head); |
42 void tern_foreach(tern_node *head, iter_fun fun, void *data); | 51 void tern_foreach(tern_node *head, iter_fun fun, void *data); |
43 char * tern_int_key(uint32_t key, char * buf); | 52 char * tern_int_key(uint32_t key, char * buf); |
44 tern_node * tern_get_node(tern_val value); | |
45 void tern_free(tern_node *head); | 53 void tern_free(tern_node *head); |
46 | 54 |
47 #endif //TERN_H_ | 55 #endif //TERN_H_ |