refactor(lsm): allow modules to import other internal header files
							parent
							
								
									c327be80e9
								
							
						
					
					
						commit
						0548efda97
					
				|  | @ -3,7 +3,7 @@ LIB_FILENAME = liblsm.a | |||
| BUILD_DIR = build | ||||
| SRC_DIR = src | ||||
| TEST_DIR = test | ||||
| INC_DIRS = include | ||||
| INC_DIRS = include src/_include | ||||
| 
 | ||||
| # -MMD: generate a .d file for every source file. This file can be imported by
 | ||||
| #  make and makes make aware that a header file has been changed, ensuring an
 | ||||
|  |  | |||
|  | @ -2,6 +2,7 @@ | |||
| #define LSM_TRIE | ||||
| 
 | ||||
| #include "lsm.h" | ||||
| #include "lsm/str.h" | ||||
| 
 | ||||
| /**
 | ||||
|  * A struct representing a trie | ||||
|  | @ -22,4 +23,38 @@ lsm_error lsm_trie_init(lsm_trie **ptr); | |||
|  */ | ||||
| void lsm_trie_free(lsm_trie *trie); | ||||
| 
 | ||||
| /**
 | ||||
|  * Insert a new element into the trie using the specified key. | ||||
|  * | ||||
|  * @param trie trie to insert into | ||||
|  * @param key key to insert data with | ||||
|  * @param data data to insert | ||||
|  */ | ||||
| lsm_error lsm_trie_insert(lsm_trie *trie, lsm_str *key, void *data); | ||||
| 
 | ||||
| /**
 | ||||
|  * Search for an element in the trie. | ||||
|  * | ||||
|  * @param out where to store data opinter, if present | ||||
|  * @param trie trie to search in | ||||
|  * @param key key to search with | ||||
|  */ | ||||
| lsm_error lsm_trie_search(void **data, lsm_trie *trie, lsm_str *key); | ||||
| 
 | ||||
| /**
 | ||||
|  * Remove an element from the trie. | ||||
|  * | ||||
|  * @param out where to store the removed data pointer, if present. | ||||
|  * @param trie trie to remove from | ||||
|  * @param key key to remove | ||||
|  */ | ||||
| lsm_error lsm_trie_remove(void **data, lsm_trie *trie, lsm_str *key); | ||||
| 
 | ||||
| /**
 | ||||
|  * Return the size of a trie | ||||
|  * | ||||
|  * @param trie trie to return size for | ||||
|  */ | ||||
| uint64_t lsm_trie_size(lsm_trie *trie); | ||||
| 
 | ||||
| #endif | ||||
|  |  | |||
|  | @ -0,0 +1,14 @@ | |||
| #ifndef LSM_TRIE_INTERNAL | ||||
| #define LSM_TRIE_INTERNAL | ||||
| 
 | ||||
| #include "lsm/bt_internal.h" | ||||
| #include "lsm/str_internal.h" | ||||
| #include "lsm/trie.h" | ||||
| 
 | ||||
| typedef struct lsm_trie_node { | ||||
|   lsm_bt bt; | ||||
|   lsm_str skip; | ||||
|   char c; | ||||
| } lsm_trie_node; | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,6 +1,6 @@ | |||
| #include <stdlib.h> | ||||
| 
 | ||||
| #include "lsm_bt_internal.h" | ||||
| #include "lsm/bt_internal.h" | ||||
| 
 | ||||
| lsm_error lsm_bt_node_init(lsm_bt_node **ptr, const char key, void *data) { | ||||
|   lsm_bt_node *node = calloc(1, sizeof(lsm_bt_node)); | ||||
|  |  | |||
|  | @ -3,7 +3,7 @@ | |||
| #include <string.h> | ||||
| 
 | ||||
| #include "lsm.h" | ||||
| #include "lsm_str_internal.h" | ||||
| #include "lsm/str_internal.h" | ||||
| 
 | ||||
| lsm_error lsm_str_init_zero(lsm_str **ptr) { | ||||
|   lsm_str *str = calloc(1, sizeof(lsm_str)); | ||||
|  | @ -0,0 +1 @@ | |||
| #include "lsm/trie_internal.h" | ||||
|  | @ -1,5 +1,5 @@ | |||
| #include "test.h" | ||||
| #include "lsm_bt_internal.h" | ||||
| #include "lsm/bt_internal.h" | ||||
| 
 | ||||
| #define BT_INIT() \ | ||||
|   lsm_bt *bt; \ | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue