Configuration entry and section deletion are now by actually deleting the item from the linked list, properly fixes the floppy/hard disk corruption bug.

This commit is contained in:
OBattler
2017-07-25 20:32:48 +02:00
parent bb0840fbe0
commit 15d90054f1

View File

@@ -81,6 +81,21 @@ typedef struct entry_t
(new)->next = NULL; \ (new)->next = NULL; \
} }
#define list_delete(old, head) \
{ \
struct list_t *cur = head; \
struct list_t *next = head; \
\
while (next->next != old) \
{ \
cur = next; \
next = next->next; \
} \
\
cur->next = next->next; \
free(next); \
}
void config_dump(void) void config_dump(void)
{ {
@@ -471,8 +486,7 @@ void config_delete_var(char *head, char *name)
if (!entry) if (!entry)
return; return;
/* memset(entry->name, 0, strlen(entry->name)); */ list_delete(&entry->list, &section->entry_head);
entry->name[0] = 0;
return; return;
} }
@@ -489,8 +503,7 @@ void config_delete_section_if_empty(char *head)
if (entries_num(section) == 0) if (entries_num(section) == 0)
{ {
/* memset(section->name, 0, strlen(section->name)); */ list_delete(&section->list, &config_head);
section->name[0] = 0;
} }
return; return;