X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fq.h;h=3834e1126b1098f0050cb72c6c9a76303021ca1c;hb=0466de1ec2360f00408c531a15aa5146e268228d;hp=6eec83c147c9ad58e099133eea0e9a2591e0e6dc;hpb=dc2f5b1a42742e40a1e5f9dfc6ecb63997e6cd09;p=swftools.git diff --git a/lib/q.h b/lib/q.h index 6eec83c..3834e11 100644 --- a/lib/q.h +++ b/lib/q.h @@ -35,6 +35,7 @@ typedef struct _mem_t { char*buffer; int len; int pos; + int read_pos; } mem_t; /* fifo buffered growing mem region */ @@ -119,6 +120,12 @@ typedef struct _heap int(*compare)(const void *, const void *); } heap_t; +typedef struct _trie { + struct _trie*row[256]; + unsigned char*rest; +} trie_t; + + char* strdup_n(const char*str, int size); unsigned int crc32_add_byte(unsigned int crc32, unsigned char b); @@ -127,6 +134,7 @@ unsigned int crc32_add_string(unsigned int crc32, const char*s); void mem_init(mem_t*mem); int mem_put(mem_t*m, void*data, int length); int mem_putstring(mem_t*m, string_t str); +int mem_get(mem_t*m, void*data, int length); void mem_clear(mem_t*mem); void mem_destroy(mem_t*mem); @@ -178,8 +186,9 @@ dict_t*dict_clone(dict_t*); void dict_foreach_keyvalue(dict_t*h, void (*runFunction)(void*data, const void*key, void*val), void*data); void dict_foreach_value(dict_t*h, void (*runFunction)(void*)); -void dict_free_all(dict_t*h, void (*freeFunction)(void*)); +void dict_free_all(dict_t*h, char free_keys, void (*free_data_function)(void*)); void dict_clear(dict_t*h); +void dict_destroy_shallow(dict_t*dict); void dict_destroy(dict_t*dict); void map_init(map_t*map); @@ -198,6 +207,9 @@ void* heap_chopmax(heap_t*h); void heap_dump(heap_t*h, FILE*fi); void** heap_flatten(heap_t*h); +void trie_put(trie_t**t, unsigned const char*id); +int trie_lookup(trie_t*t, unsigned const char*id); + array_t* array_new(); array_t* array_new2(type_t*type); void array_free(array_t*array); @@ -223,12 +235,14 @@ void*list_clone_(void*_list); void list_append_(void*_list, void*entry); void list_prepend_(void*_list, void*entry); void list_free_(void*_list); +void list_deep_free_(void*_list); void list_concat_(void*l1, void*l2); #define list_new() ((void*)0) #define list_append(list, e) {sizeof((list)->next);list_append_(&(list),(e));} #define list_concat(l1, l2) {sizeof((l1)->next);sizeof((l2)->next);list_concat_(&(l1),&(l2));} #define list_prepend(list, e) {sizeof((list)->next);list_prepend_(&(list),(e));} #define list_free(list) {sizeof((list)->next);list_free_(&(list));} +#define list_deep_free(list) {sizeof((list)->next);list_deep_free_(&(list));} #define list_clone(list) (sizeof((list)->next),list_clone_(&(list))) #define list_length(list) (sizeof((list)->next),list_length_(list))