diff --git a/core/blob_list.c b/core/blob_list.c index 8f53986..a0173f8 100644 --- a/core/blob_list.c +++ b/core/blob_list.c @@ -4,6 +4,7 @@ */ #include +#include #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); + } +} diff --git a/inc/blobchain/blob.h b/inc/blobchain/blob.h index cdf8a97..c0b9639 100644 --- a/inc/blobchain/blob.h +++ b/inc/blobchain/blob.h @@ -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 */