summaryrefslogtreecommitdiffstats
path: root/src/usr/imgmgmt.c
diff options
context:
space:
mode:
authorMichael Brown2007-01-12 10:46:10 +0100
committerMichael Brown2007-01-12 10:46:10 +0100
commite2c0055e2393926a0c7424eb3df11fd7501b54f6 (patch)
treeaca53cf0cda11a87bc447562988207bc8fd05023 /src/usr/imgmgmt.c
parentAdded dhcp() user-level command. (diff)
downloadipxe-e2c0055e2393926a0c7424eb3df11fd7501b54f6.tar.gz
ipxe-e2c0055e2393926a0c7424eb3df11fd7501b54f6.tar.xz
ipxe-e2c0055e2393926a0c7424eb3df11fd7501b54f6.zip
Let ifmgmt.c take care of calling efree(), since it's the once which
took out the contract to eventually call efree() when it called fetch(). Maintain the most recently loaded image at the start of the list, so that imgautoselect() will pick it.
Diffstat (limited to 'src/usr/imgmgmt.c')
-rw-r--r--src/usr/imgmgmt.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/usr/imgmgmt.c b/src/usr/imgmgmt.c
index 6a2599d5..eb2330a3 100644
--- a/src/usr/imgmgmt.c
+++ b/src/usr/imgmgmt.c
@@ -21,6 +21,7 @@
#include <errno.h>
#include <vsprintf.h>
#include <gpxe/image.h>
+#include <gpxe/emalloc.h>
#include <usr/fetch.h>
#include <usr/imgmgmt.h>
@@ -65,7 +66,7 @@ int imgfetch ( const char *filename, const char *name,
return 0;
err:
- free_image ( image );
+ efree ( image->data );
free ( image );
return rc;
}
@@ -77,7 +78,16 @@ int imgfetch ( const char *filename, const char *name,
* @ret rc Return status code
*/
int imgload ( struct image *image ) {
- return image_autoload ( image );
+ int rc;
+
+ /* Try to load image */
+ if ( ( rc = image_autoload ( image ) ) != 0 )
+ return rc;
+
+ /* If we succeed, move the image to the start of the list */
+ promote_image ( image );
+
+ return 0;
}
/**
@@ -129,6 +139,6 @@ void imgstat ( struct image *image ) {
*/
void imgfree ( struct image *image ) {
unregister_image ( image );
- free_image ( image );
+ efree ( image->data );
free ( image );
}