core: blob: Add helper to destroy blob list

Signed-off-by: Chloe M. <chloe@mirocom.org>
This commit is contained in:
2026-04-30 14:14:52 -04:00
parent 09e0774d12
commit 83a0ef6e2e
2 changed files with 27 additions and 0 deletions
+20
View File
@@ -4,6 +4,7 @@
*/
#include <errno.h>
#include <stdlib.h>
#include "blobchain/blob.h"
#include "blobchain/memlib.h"
@@ -45,3 +46,22 @@ blob_list_append(struct blob_list *lp, struct blob *blob)
++lp->count;
return 0;
}
void
blob_list_destroy(struct blob_list *lp)
{
struct blob *bp, *tmp;
if (lp == NULL) {
return;
}
bp = lp->head;
while (bp != NULL) {
tmp = bp;
bp = bp->next;
free(tmp->data);
free(tmp);
}
}
+7
View File
@@ -60,4 +60,11 @@ int blob_list_append(struct blob_list *lp, struct blob *blob);
*/
int blob_list_init(struct blob_list *lp);
/*
* Destroy a blob list
*
* @lp: Bloblist to destroy
*/
void blob_list_destroy(struct blob_list *lp);
#endif /* !BLOBCHAIN_BLOB_H */