core: blob: Add helper to destroy blob list
Signed-off-by: Chloe M. <chloe@mirocom.org>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user