X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=common%2Ftrie.c;h=9a04cf47c9bf0f332d0d45d819aa7298a76e4384;hb=0f6506ab48115315e2762b59bba41b592884fdef;hp=dc84236da7e962d96cc81cd6525d2ca1b9fb6fae;hpb=12b47d65a20c3a3b6af86f828c77a77449d527c9;p=apps%2Fpfixtools.git diff --git a/common/trie.c b/common/trie.c index dc84236..9a04cf4 100644 --- a/common/trie.c +++ b/common/trie.c @@ -229,6 +229,7 @@ static inline void trie_entry_split(trie_t *trie, trie_entry_t *entry, int pos) void trie_insert(trie_t *trie, const char* key) { + assert(trie->entries == NULL && "Trie already compiled"); GROW(trie->keys, 1, trie->keys_len, trie->keys_size); trie->keys[trie->keys_len++] = strdup(key); } @@ -298,6 +299,8 @@ typedef char *str_t; void trie_compile(trie_t *trie, bool memlock) { + assert(trie->entries == NULL && "Trie already compiled"); + assert(trie->keys != NULL && "Trying to compile an empty trie"); { # define QSORT_TYPE str_t # define QSORT_BASE trie->keys @@ -318,6 +321,7 @@ void trie_compile(trie_t *trie, bool memlock) bool trie_lookup(const trie_t *trie, const char *key) { + assert(trie->keys == NULL && "Can't lookup: trie not compiled"); if (trie->entries_len == 0) { return false; } else {