refactor: remove entry code from trie
parent
4b772d003b
commit
0c742f45b0
|
@ -4,7 +4,7 @@ project(lander C CXX)
|
|||
set(CMAKE_C_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
include_directories(trie/include)
|
||||
include_directories(include trie/include)
|
||||
add_subdirectory(crow)
|
||||
add_subdirectory(trie)
|
||||
|
||||
|
@ -15,6 +15,6 @@ else()
|
|||
add_compile_options(-O3 -flto)
|
||||
endif()
|
||||
|
||||
add_executable(lander src/main.cpp)
|
||||
add_executable(lander src/main.cpp src/entry.c)
|
||||
target_link_libraries(lander PUBLIC Crow::Crow trie)
|
||||
endif()
|
||||
|
|
2
Makefile
2
Makefile
|
@ -1,7 +1,7 @@
|
|||
# =====CONFIG=====
|
||||
BUILD_DIR := ./build
|
||||
SRC_DIRS := ./src ./trie/src
|
||||
INCLUDE_DIRS := ./trie/include
|
||||
INCLUDE_DIRS := ./trie/include ./include
|
||||
TEST_DIR := test
|
||||
CORES != nproc
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef LANDER_ENTRY
|
||||
#define LANDER_ENTRY
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum entry_type { Redirect, Paste, Unknown } EntryType;
|
||||
|
||||
typedef struct entry {
|
||||
EntryType type;
|
||||
char string[];
|
||||
} Entry;
|
||||
|
||||
uint64_t entry_new(Entry **entry_ptr, EntryType type, const char *string);
|
||||
|
||||
void entry_free(Entry *entry);
|
||||
|
||||
#endif
|
|
@ -1,5 +1,6 @@
|
|||
#include "trie.h"
|
||||
#include "entry.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
EntryType entry_type_from_char(char c) {
|
||||
switch (c) {
|
|
@ -4,6 +4,7 @@
|
|||
#include "crow.h"
|
||||
|
||||
extern "C" {
|
||||
#include "entry.h"
|
||||
#include "trie.h"
|
||||
}
|
||||
|
||||
|
|
|
@ -38,13 +38,6 @@ static const size_t charset_len = sizeof(charset) - 1;
|
|||
*/
|
||||
typedef struct ttrie Trie;
|
||||
|
||||
typedef enum entry_type { Redirect, Paste, Unknown } EntryType;
|
||||
|
||||
typedef struct entry {
|
||||
EntryType type;
|
||||
char string[];
|
||||
} Entry;
|
||||
|
||||
typedef enum trie_exit_code {
|
||||
Ok = 0,
|
||||
NotFound,
|
||||
|
@ -52,10 +45,6 @@ typedef enum trie_exit_code {
|
|||
FileError
|
||||
} TrieExitCode;
|
||||
|
||||
uint64_t entry_new(Entry **entry_ptr, EntryType type, const char *string);
|
||||
|
||||
void entry_free(Entry *entry);
|
||||
|
||||
/**
|
||||
* Allocate & initialize a new trie, and populate it with the data from the
|
||||
* given data file.
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "trie.h"
|
||||
#include "trie_entry.c"
|
||||
#include "trie_node.c"
|
||||
|
||||
typedef struct ttrie {
|
||||
|
|
Loading…
Reference in New Issue