summaryrefslogtreecommitdiff
path: root/entry.c
diff options
context:
space:
mode:
authorlouie <lshprung@yahoo.com>2020-07-13 15:09:01 -0700
committerlouie <lshprung@yahoo.com>2020-07-13 15:09:01 -0700
commit40a6bba7765b661303ed0e1e6f6f7319e344ce08 (patch)
treed5e99caeb36c6bb9300a43efd1a11201534499ea /entry.c
parent2d08a7dbceac846f54cba6b0b75b0de1542df707 (diff)
Fixed entry deletion, added addR option
Diffstat (limited to 'entry.c')
-rw-r--r--entry.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/entry.c b/entry.c
index a74f18e..d455f6b 100644
--- a/entry.c
+++ b/entry.c
@@ -17,7 +17,8 @@ typedef struct entry{
} ENTRY;
ENTRY *create_entry(char *new_name, char *new_path, bool force);
-void entry_rm(ENTRY *e);
+void entry_rm(ENTRY *e, ENTRY *prev);
+void clear_entries(ENTRY *head);
ENTRY *entry_add_last(ENTRY *tail, ENTRY *add);
ENTRY **get_entries(ENTRY *head, int count);
char *get_ename(ENTRY *e);
@@ -38,11 +39,24 @@ ENTRY *create_entry(char *new_name, char *new_path, bool force){
return new;
}
-void entry_rm(ENTRY *e){
+void entry_rm(ENTRY *e, ENTRY *prev){
assert(e != NULL);
+ if(prev != NULL) prev->next = e->next; //maintain linked structure
free(e);
}
+void clear_entries(ENTRY *head){
+ ENTRY *temp;
+
+ while(head != NULL){
+ temp = head;
+ head = head->next;
+ free(temp);
+ }
+
+ return;
+}
+
ENTRY *entry_add_last(ENTRY *tail, ENTRY *add){
assert(add != NULL);