aboutsummaryrefslogtreecommitdiff
path: root/src/storage.c
diff options
context:
space:
mode:
authorSoikk2022-08-13 18:49:30 +0200
committerSoikk2022-08-13 18:49:30 +0200
commit4b721332d570f53719894af922c22b7cba146b18 (patch)
tree9c5b8f75345310cd7f2479fca0ebaf20c7ca47dc /src/storage.c
parent32dd785f881cf3ba6c1c6806cd3af3cbf56437c4 (diff)
downloadsoikk-DB-4b721332d570f53719894af922c22b7cba146b18.tar.xz
soikk-DB-4b721332d570f53719894af922c22b7cba146b18.tar.zst
Added primitive repl, delete functions for database and remove tag from file function.
Diffstat (limited to 'src/storage.c')
-rw-r--r--src/storage.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/storage.c b/src/storage.c
index 9afede7..bc5ab6b 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -10,6 +10,13 @@ ltable *newLtable(uint64_t size){
return lt;
}
+int deleteLtable(ltable **lt){
+ free((*lt)->table);
+ free(*lt);
+ *lt = NULL;
+ return 0;
+}
+
int insertLtable(ltable *lt, char *str){
uint32_t ls;
str = normalizeStrLimit(str, &ls, MAXPATH-1);
@@ -105,6 +112,13 @@ ctable *newCtable(uint64_t size){
return ct;
}
+int deleteCtable(ctable **ct){
+ free((*ct)->table);
+ free(*ct);
+ *ct = NULL;
+ return 0;
+}
+
int insertCtable(ctable *ct, uint64_t n){
uint64_t *nct = malloc((ct->size+1)*sizeof(uint64_t));
for(uint64_t i = 0; i < ct->size; ++i){
@@ -184,6 +198,13 @@ mtable *newMtable(uint64_t size){
return mt;
}
+int deleteMtable(mtable **mt){
+ free((*mt)->table);
+ free(*mt);
+ *mt = NULL;
+ return 0;
+}
+
int insertMtable(mtable *mt, relation r){
relation *nmt = malloc((mt->size+1)*sizeof(relation));
for(uint64_t i = 0; i < mt->size; ++i){
@@ -301,6 +322,17 @@ node *newNode(uint64_t h, uint64_t i){
return n;
}
+int deleteTree(tree *root){
+ if(*root == NULL){
+ return -1;
+ }
+ deleteTree(&(*root)->left);
+ deleteTree(&(*root)->right);
+ free(*root);
+ *root = NULL;
+ return 0;
+}
+
static node *rotateNodeRight(node *r){
node *nr = r->left;
node *nc = nr->right;