]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
realloc
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 3 Aug 2009 12:30:51 +0000 (14:30 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 3 Aug 2009 12:30:51 +0000 (14:30 +0200)
include/grub/i386/relocator.h
lib/i386/relocator.c

index cbc75ed0a1bc8a75b264a3d83db40b3342e5be2b..ef7fe23aaebb2d94025ae8af6ff9214c425fa8c1 100644 (file)
@@ -19,6 +19,9 @@
 #ifndef GRUB_RELOCATOR_CPU_HEADER
 #define GRUB_RELOCATOR_CPU_HEADER      1
 
+#include <grub/types.h>
+#include <grub/err.h>
+
 struct grub_relocator32_state
 {
   grub_uint32_t esp;
@@ -29,12 +32,10 @@ struct grub_relocator32_state
   grub_uint32_t eip;
 };
 
-void *
-grub_relocator32_alloc (grub_size_t size);
-grub_err_t
-grub_relocator32_boot (void *relocator, grub_uint32_t dest,
-                      struct grub_relocator32_state state);
-void
-grub_relocator32_free (void *relocator);
+void *grub_relocator32_alloc (grub_size_t size);
+grub_err_t grub_relocator32_boot (void *relocator, grub_uint32_t dest,
+                                 struct grub_relocator32_state state);
+void *grub_relocator32_realloc (void *relocator, grub_size_t size);
+void grub_relocator32_free (void *relocator);
 
 #endif /* ! GRUB_RELOCATOR_CPU_HEADER */
index 6a9b3ce1bbeae861d92509c637e2a6d3dd9edb61..0205d8ef48038d83245e31a0a3f5c2068db9b148 100644 (file)
@@ -80,6 +80,25 @@ grub_relocator32_alloc (grub_size_t size)
   return playground + RELOCATOR_SIZEOF (forward);
 }
 
+void *
+grub_relocator32_realloc (void *relocator, grub_size_t size)
+{
+  char *playground;
+
+  playground = (char *) relocator - RELOCATOR_SIZEOF (forward);
+
+  playground = grub_realloc (playground,
+                            (RELOCATOR_SIZEOF (forward) + RELOCATOR_ALIGN)
+                            + size
+                            + (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN));
+  if (!playground)
+    return 0;
+
+  *(grub_size_t *) playground = size;
+
+  return playground + RELOCATOR_SIZEOF (forward);
+}
+
 void
 grub_relocator32_free (void *relocator)
 {