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 <errno.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "blobchain/blob.h"
|
#include "blobchain/blob.h"
|
||||||
#include "blobchain/memlib.h"
|
#include "blobchain/memlib.h"
|
||||||
|
|
||||||
@@ -45,3 +46,22 @@ blob_list_append(struct blob_list *lp, struct blob *blob)
|
|||||||
++lp->count;
|
++lp->count;
|
||||||
return 0;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -60,4 +60,11 @@ int blob_list_append(struct blob_list *lp, struct blob *blob);
|
|||||||
*/
|
*/
|
||||||
int blob_list_init(struct blob_list *lp);
|
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 */
|
#endif /* !BLOBCHAIN_BLOB_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user