[util] Fix a linked-list error in segtext
Uncovered by the memory leak cleanup: the nodes were all being "linked" to the first node, those nodes in between the first and last were getting lost.
This commit is contained in:
parent
13f8f2b66b
commit
d8466b6cca
|
@ -163,6 +163,7 @@ Segtext_new (const char *source_string)
|
||||||
// If tags are duplicated, the first one takes precedence
|
// If tags are duplicated, the first one takes precedence
|
||||||
if ((*chunk)->tag && !Hash_Find (text->tab, (*chunk)->tag))
|
if ((*chunk)->tag && !Hash_Find (text->tab, (*chunk)->tag))
|
||||||
Hash_Add (text->tab, *chunk);
|
Hash_Add (text->tab, *chunk);
|
||||||
|
chunk = &(*chunk)->next;
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
@ -177,8 +178,9 @@ Segtext_delete (segtext_t *st)
|
||||||
while (st->chunk_list) {
|
while (st->chunk_list) {
|
||||||
chunk = st->chunk_list;
|
chunk = st->chunk_list;
|
||||||
st->chunk_list = chunk->next;
|
st->chunk_list = chunk->next;
|
||||||
if (chunk->tag)
|
if (chunk->tag) {
|
||||||
free ((char *) chunk->tag);
|
free ((char *) chunk->tag);
|
||||||
|
}
|
||||||
delete_chunk (chunk);
|
delete_chunk (chunk);
|
||||||
}
|
}
|
||||||
Hash_DelTable (st->tab);
|
Hash_DelTable (st->tab);
|
||||||
|
|
Loading…
Reference in New Issue