From 742f24286359486e31809e028c06929340106284 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 12 Jan 2007 06:26:59 +0000 Subject: [PATCH] Add free_image --- src/core/image.c | 17 +++++++++++++++++ src/include/gpxe/image.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/core/image.c b/src/core/image.c index e14e08f1..51998982 100644 --- a/src/core/image.c +++ b/src/core/image.c @@ -89,6 +89,23 @@ struct image * find_image ( const char *name ) { return NULL; } +/** + * Free loaded image + * + * @v image Executable/loadable image + * + * This releases the memory being used to store the image; it does not + * release the @c struct @c image itself, nor does it unregister the + * image. + */ +void free_image ( struct image *image ) { + if ( image->free ) + image->free ( image->data ); + image->free = NULL; + image->data = UNULL; + image->len = 0; +} + /** * Load executable/loadable image into memory * diff --git a/src/include/gpxe/image.h b/src/include/gpxe/image.h index fc955c2e..7f11e6a0 100644 --- a/src/include/gpxe/image.h +++ b/src/include/gpxe/image.h @@ -109,6 +109,7 @@ extern struct list_head images; extern int register_image ( struct image *image ); extern void unregister_image ( struct image *image ); struct image * find_image ( const char *name ); +extern void free_image ( struct image *image ); extern int image_load ( struct image *image ); extern int image_autoload ( struct image *image ); extern int image_exec ( struct image *image );