Add romfile_loadfile() helper function.

Add function to find, malloc, and copy a romfile.  Use it in the
bootsplash and bootorder code.
diff --git a/src/boot.c b/src/boot.c
index 9c37023..4fb73ac 100644
--- a/src/boot.c
+++ b/src/boot.c
@@ -68,24 +68,10 @@
             IPL.checkfloppysig = 1;
     }
 
-    u32 file = romfile_find("bootorder");
-    if (!file)
+    char *f = romfile_loadfile("bootorder", NULL);
+    if (!f)
         return;
 
-    int filesize = romfile_size(file);
-    dprintf(3, "bootorder file found (len %d)\n", filesize);
-
-    if (filesize == 0)
-        return;
-
-    char *f = malloc_tmphigh(filesize);
-
-    if (!f) {
-        warn_noalloc();
-        return;
-    }
-
-    romfile_copy(file, f, filesize);
     int i;
     IPL.fw_bootorder_count = 1;
     while(f[i]) {
diff --git a/src/bootsplash.c b/src/bootsplash.c
index 8f42dfd..cf1a603 100644
--- a/src/bootsplash.c
+++ b/src/bootsplash.c
@@ -149,17 +149,16 @@
     if (!CONFIG_BOOTSPLASH)
         return;
     dprintf(3, "Checking for bootsplash\n");
-    u32 file = romfile_find("bootsplash.jpg");
-    if (!file)
+    int filesize;
+    u8 *filedata = romfile_loadfile("bootsplash.jpg", &filesize);
+    if (!filedata)
         return;
-    int filesize = romfile_size(file);
 
     u8 *picture = NULL;
-    u8 *filedata = malloc_tmphigh(filesize);
     struct vesa_info *vesa_info = malloc_tmplow(sizeof(*vesa_info));
     struct vesa_mode_info *mode_info = malloc_tmplow(sizeof(*mode_info));
     struct jpeg_decdata *jpeg = jpeg_alloc();
-    if (!filedata || !jpeg || !vesa_info || !mode_info) {
+    if (!jpeg || !vesa_info || !mode_info) {
         warn_noalloc();
         goto done;
     }
@@ -186,8 +185,6 @@
             vendor, product);
 
     // Parse jpeg and get image size.
-    dprintf(5, "Copying bootsplash.jpg\n");
-    romfile_copy(file, filedata, filesize);
     dprintf(5, "Decoding bootsplash.jpg\n");
     int ret = jpeg_decode(jpeg, filedata);
     if (ret) {
diff --git a/src/paravirt.c b/src/paravirt.c
index 308c809..74d3743 100644
--- a/src/paravirt.c
+++ b/src/paravirt.c
@@ -365,3 +365,30 @@
     qemu_cfg_read_entry(dst, select, len);
     return len;
 }
+
+// Helper function to find, malloc_tmphigh, and copy a romfile.  This
+// function adds a trailing zero to the malloc'd copy.
+void *
+romfile_loadfile(const char *name, int *psize)
+{
+    u32 file = romfile_find(name);
+    if (!file)
+        return NULL;
+
+    int filesize = romfile_size(file);
+    if (!filesize)
+        return NULL;
+
+    char *data = malloc_tmphigh(filesize+1);
+    if (!data) {
+        warn_noalloc();
+        return NULL;
+    }
+
+    dprintf(5, "Copying romfile '%s' (len %d)\n", name, filesize);
+    romfile_copy(file, data, filesize);
+    if (psize)
+        *psize = filesize;
+    data[filesize] = '\0';
+    return data;
+}
diff --git a/src/paravirt.h b/src/paravirt.h
index 99c473b..7bf34b1 100644
--- a/src/paravirt.h
+++ b/src/paravirt.h
@@ -100,6 +100,7 @@
         return cbfs_filename((void*)fileid);
     return qemu_cfg_name_file(fileid);
 }
+void *romfile_loadfile(const char *name, int *psize);
 
 u32 qemu_cfg_e820_entries(void);
 void* qemu_cfg_e820_load_next(void *addr);