core: balloon: Add balloon_free() function
Signed-off-by: Chloe M. <chloe@mirocom.org>
This commit is contained in:
@@ -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);
|
memcpy((char *)dest->data + off, source, count);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
balloon_free(struct mvm_balloon *bp)
|
||||||
|
{
|
||||||
|
if (bp == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bp->data != NULL) {
|
||||||
|
free(bp->data);
|
||||||
|
bp->data = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -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);
|
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 */
|
#endif /* !MVM_BALLOON_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user