From bf49cd33a30aa6325872fb29ad0669bb5b5852fb Mon Sep 17 00:00:00 2001 From: "Chloe M." Date: Sun, 24 May 2026 17:02:40 -0500 Subject: [PATCH] core: balloon: Add balloon_free() function Signed-off-by: Chloe M. --- mvm/core/balloon_subr.c | 13 +++++++++++++ mvm/include/mvm/balloon.h | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/mvm/core/balloon_subr.c b/mvm/core/balloon_subr.c index 68ab7b8..2a4b584 100644 --- a/mvm/core/balloon_subr.c +++ b/mvm/core/balloon_subr.c @@ -73,3 +73,16 @@ balloon_memcpy(struct mvm_balloon *dest, off_t off, void *source, size_t count) memcpy((char *)dest->data + off, source, count); return 0; } + +void +balloon_free(struct mvm_balloon *bp) +{ + if (bp == NULL) { + return; + } + + if (bp->data != NULL) { + free(bp->data); + bp->data = NULL; + } +} diff --git a/mvm/include/mvm/balloon.h b/mvm/include/mvm/balloon.h index 26a2609..cb12c6a 100644 --- a/mvm/include/mvm/balloon.h +++ b/mvm/include/mvm/balloon.h @@ -50,4 +50,11 @@ int balloon_init(struct mvm_balloon *bp, size_t cap); */ int balloon_memcpy(struct mvm_balloon *dest, off_t off, void *source, size_t count); +/* + * Release a balloon from memory + * + * @bp: Balloon to free + */ +void balloon_free(struct mvm_balloon *bp); + #endif /* !MVM_BALLOON_H */