srcpos: Define srcpos_free

srcpos can be chained together using srcpos_extend. However, in such
cases, we need to free all the chained nodes.

srcpos_free is a helper to recursively free all the linked srcpos.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
Message-ID: <20250605-previous-value-v3-1-0983d0733a07@beagleboard.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Ayush Singh 2025-06-05 16:18:06 +05:30 committed by David Gibson
parent e0b7749c26
commit b841391bbd
3 changed files with 13 additions and 1 deletions

View file

@ -287,6 +287,17 @@ struct srcpos *srcpos_extend(struct srcpos *pos, struct srcpos *newtail)
return pos;
}
void srcpos_free(struct srcpos *pos)
{
struct srcpos *p_next;
while (pos) {
p_next = pos->next;
free(pos);
pos = p_next;
}
}
char *
srcpos_string(struct srcpos *pos)
{