aboutsummaryrefslogtreecommitdiff
path: root/src/sc_parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sc_parse.c')
-rw-r--r--src/sc_parse.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/sc_parse.c b/src/sc_parse.c
index 1018d24..ccc6f6a 100644
--- a/src/sc_parse.c
+++ b/src/sc_parse.c
@@ -218,14 +218,14 @@ void sc_block_substitute(SCBlock **top, SCBlock *old, SCBlock *new)
new->next = old->next;
*top = new;
} else {
- sc_block_delete(*top, old);
+ sc_block_unlink(*top, old);
sc_block_append_p(new, *top);
}
}
/* Delete "deleteme", which is somewhere under "top" */
-void sc_block_delete(SCBlock *top, SCBlock *deleteme)
+void sc_block_unlink(SCBlock *top, SCBlock *deleteme)
{
SCBlock *parent = sc_find_parent(top, deleteme);
if ( parent == NULL ) {
@@ -240,19 +240,24 @@ void sc_block_delete(SCBlock *top, SCBlock *deleteme)
if ( parent->child == deleteme ) {
parent->child = NULL;
}
+}
+
+void sc_block_delete(SCBlock *top, SCBlock *deleteme)
+{
+ sc_block_unlink(top, deleteme);
sc_block_free(deleteme);
}
-
-/* Frees "bl" and all its children */
+/* Frees "bl" and all its children (but not the blocks following it) */
void sc_block_free(SCBlock *bl)
{
if ( bl->child != NULL ) {
SCBlock *ch = bl->child;
while ( ch != NULL ) {
+ SCBlock *next = ch->next;
sc_block_free(ch);
- ch = ch->next;
+ ch = next;;
}
}