feat: use custom binary file format for data
This commit is contained in:
parent
c99bc83015
commit
4b772d003b
4 changed files with 69 additions and 59 deletions
|
|
@ -42,7 +42,7 @@ typedef enum entry_type { Redirect, Paste, Unknown } EntryType;
|
|||
|
||||
typedef struct entry {
|
||||
EntryType type;
|
||||
char *string;
|
||||
char string[];
|
||||
} Entry;
|
||||
|
||||
typedef enum trie_exit_code {
|
||||
|
|
@ -52,7 +52,7 @@ typedef enum trie_exit_code {
|
|||
FileError
|
||||
} TrieExitCode;
|
||||
|
||||
Entry *entry_new(EntryType type, const char *string);
|
||||
uint64_t entry_new(Entry **entry_ptr, EntryType type, const char *string);
|
||||
|
||||
void entry_free(Entry *entry);
|
||||
|
||||
|
|
@ -89,7 +89,8 @@ TrieExitCode trie_search(Trie *trie, void **data_ptr, const char *key);
|
|||
* @param entry entry to add
|
||||
* @return 0 if added, 1 if already in trie, something else if other errors
|
||||
*/
|
||||
TrieExitCode trie_add(Trie *trie, const char *key, void *data);
|
||||
TrieExitCode trie_add(Trie *trie, const char *key, void *data,
|
||||
uint64_t data_len);
|
||||
|
||||
/**
|
||||
* Add an entry by generating a random string as the key.
|
||||
|
|
@ -101,7 +102,7 @@ TrieExitCode trie_add(Trie *trie, const char *key, void *data);
|
|||
* unlocking the trie, and should be freed manually.
|
||||
*/
|
||||
TrieExitCode trie_add_random(Trie *trie, char **key_ptr, void *data,
|
||||
bool secure);
|
||||
uint64_t data_len, bool secure);
|
||||
|
||||
/**
|
||||
* Remove an entry from this trie given its key.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue