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:
21
src/config.c
21
src/config.c
@@ -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, §ion->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(§ion->list, &config_head);
|
||||||
section->name[0] = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user