diff --git a/Makefile b/Makefile index ca64c3b..9e98f19 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ $(TARGETS_MEM_TEST): test-mem-%: % .PHONY: build-test build-test: $(BINS_TEST) -$(BINS_TEST): %: %.c.o $(BIN) +$(BINS_TEST): %: %.c.o $(CC) \ $^ -o $@ diff --git a/trie/include/trie.h b/include/trie.h similarity index 100% rename from trie/include/trie.h rename to include/trie.h diff --git a/src/main.c b/src/main.c index 99ca6c8..d3a840c 100644 --- a/src/main.c +++ b/src/main.c @@ -50,14 +50,14 @@ int main() { info("Initializing trie"); - Trie *trie = trie_init(); - int count = trie_populate(trie, "lander.data"); + Trie *trie; + TrieExitCode res = trie_init(&trie, "lander.data"); - if (count < 0) { + if (res != Ok) { critical(1, "An error occured while populating the trie."); } - info("Trie initialized and populated with %i entries", count); + info("Trie initialized and populated with %i entries", trie_size(trie)); http_loop_gctx *gctx = http_loop_gctx_init(); gctx->trie = trie; diff --git a/trie/src/trie.c b/src/trie/trie.c similarity index 99% rename from trie/src/trie.c rename to src/trie/trie.c index 9803b79..727d3da 100644 --- a/trie/src/trie.c +++ b/src/trie/trie.c @@ -5,8 +5,8 @@ #include #include "trie.h" -#include "trie_entry.c" -#include "trie_node.c" +#include "trie_entry.h" +#include "trie_node.h" typedef struct ttrie { TrieNode *root; diff --git a/trie/src/trie_entry.c b/src/trie/trie_entry.c similarity index 95% rename from trie/src/trie_entry.c rename to src/trie/trie_entry.c index 2ddec08..2aa8cdf 100644 --- a/trie/src/trie_entry.c +++ b/src/trie/trie_entry.c @@ -1,4 +1,4 @@ -#include "trie.h" +#include "trie_entry.h" #include EntryType entry_type_from_char(char c) { diff --git a/src/trie/trie_entry.h b/src/trie/trie_entry.h new file mode 100644 index 0000000..b3ca8cd --- /dev/null +++ b/src/trie/trie_entry.h @@ -0,0 +1,7 @@ +#include "trie.h" + +EntryType entry_type_from_char(char c); + +char entry_type_to_char(EntryType et); + +Entry *entry_new(EntryType type, const char *string); diff --git a/trie/src/trie_node.c b/src/trie/trie_node.c similarity index 100% rename from trie/src/trie_node.c rename to src/trie/trie_node.c diff --git a/trie/src/trie_node.h b/src/trie/trie_node.h similarity index 100% rename from trie/src/trie_node.h rename to src/trie/trie_node.h diff --git a/trie/test/test.h b/test/test.h similarity index 100% rename from trie/test/test.h rename to test/test.h diff --git a/trie/test/fuzzy.h b/test/trie/fuzzy.h similarity index 100% rename from trie/test/fuzzy.h rename to test/trie/fuzzy.h diff --git a/trie/test/test_trie.c b/test/trie/test_trie.c similarity index 100% rename from trie/test/test_trie.c rename to test/trie/test_trie.c diff --git a/trie/test/test_trie_fuzzy.c b/test/trie/test_trie_fuzzy.c similarity index 100% rename from trie/test/test_trie_fuzzy.c rename to test/trie/test_trie_fuzzy.c diff --git a/trie/CMakeLists.txt b/trie/CMakeLists.txt deleted file mode 100644 index 7b89570..0000000 --- a/trie/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -include_directories(include) - -if(CMAKE_BUILD_TYPE MATCHES "^Test") - enable_testing() - add_subdirectory(test) -endif() - -add_library(trie STATIC include/trie.h src/trie.c) diff --git a/trie/README.md b/trie/README.md deleted file mode 100644 index 26fa38a..0000000 --- a/trie/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Trie design - -This trie is a modified version of the custom trie I had to implement for my -Algorithms & Datastructures 3 course. diff --git a/trie/test/CMakeLists.txt b/trie/test/CMakeLists.txt deleted file mode 100644 index fdd8f31..0000000 --- a/trie/test/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -add_compile_options(-Wno-incompatible-pointer-types) - -add_executable(test_trie test_trie.c ../src/trie.c) -add_test(NAME test_trie COMMAND test_trie) -add_executable(test_trie_fuzzy test_trie_fuzzy.c ../src/trie.c) -add_test(NAME test_trie_fuzzy COMMAND test_trie_fuzzy)