I will murder cmake

This commit is contained in:
Jef Roosens 2022-11-15 17:05:14 +01:00
parent 0b97f124c5
commit 614ae1c711
Signed by: Jef Roosens
GPG key ID: B75D4F293C7052DB
5 changed files with 23 additions and 15 deletions

View file

@ -1,8 +1,12 @@
cmake_minimum_required(VERSION 3.20)
project(AD3-project-2022-2023 C)
project(ternarytrie C)
set(CMAKE_C_STANDARD 17)
include_directories(include)
add_library(ternarytrie STATIC include/ternarytrie.h src/ternarytrie.c)
add_library(ternarytrie STATIC src/ternarytrie.c)
target_include_directories(
ternarytrie PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)

View file

@ -14,7 +14,7 @@ typedef struct ttrie {
*
* @return pointer to the empty TernaryTrie
*/
inline TernaryTrie *ternarytrie_init() {
TernaryTrie *ternarytrie_init() {
TernaryTrie *node = calloc(1, sizeof(TernaryTrie));
node->root = ttnode_init();
@ -26,7 +26,7 @@ inline TernaryTrie *ternarytrie_init() {
*
* @param trie trie to free
*/
inline void ternarytrie_free(TernaryTrie *trie) {
void ternarytrie_free(TernaryTrie *trie) {
ttnode_free(trie->root);
free(trie);
}
@ -94,7 +94,7 @@ SearchResult ternarytrie_search_node(TernaryTrie *trie, const char *string) {
* @param string string to look up
* @return true if the string is present in the trie, false otherwise
*/
inline bool ternarytrie_search(TernaryTrie *trie, const char *string) {
bool ternarytrie_search(TernaryTrie *trie, const char *string) {
SearchResult res = ternarytrie_search_node(trie, string);
return res.child != NULL;
@ -244,4 +244,4 @@ bool ternarytrie_remove(TernaryTrie *trie, const char *string) {
* @param trie trie to return size for
* @return size of the trie
*/
inline size_t ternarytrie_size(TernaryTrie *trie) { return trie->size; }
size_t ternarytrie_size(TernaryTrie *trie) { return trie->size; }

View file

@ -51,7 +51,7 @@ void ttnode_free(TernaryTrieNode *node);
* @param c character to represent
* @return pointer to newly allocated struct
*/
inline TernaryTrieInnerNode *ttinode_init(char c) {
TernaryTrieInnerNode *ttinode_init(char c) {
TernaryTrieInnerNode *node = calloc(1, sizeof(TernaryTrieInnerNode));
node->key = c;
@ -63,7 +63,7 @@ inline TernaryTrieInnerNode *ttinode_init(char c) {
*
* @return pointer to newly allocated struct
*/
inline TernaryTrieNode *ttnode_init() { return calloc(1, sizeof(TernaryTrieNode)); }
TernaryTrieNode *ttnode_init() { return calloc(1, sizeof(TernaryTrieNode)); }
/**
* Free a TernaryTrieInnerNode and its underlying tree structure. This should
@ -109,7 +109,7 @@ void ttnode_free(TernaryTrieNode *node) {
* @param node node to add string to
* @param string string to add
*/
inline void ttnode_set_string(TernaryTrieNode *node, const char *string) {
void ttnode_set_string(TernaryTrieNode *node, const char *string) {
node->type = 2;
node->size = strlen(string);
node->ptr.string = my_strdup(string);
@ -301,7 +301,7 @@ void ttinode_remove(TernaryTrieInnerNode *node, const char c) {
* @param node node to remove character from
* @param c character to remove
*/
inline void ttnode_remove(TernaryTrieNode *node, const char c) {
void ttnode_remove(TernaryTrieNode *node, const char c) {
ttinode_remove(node->ptr.root, c);
node->size--;