Quick and dirty test for emalloc()
authorMichael Brown <mcb30@etherboot.org>
Fri, 12 Jan 2007 03:27:05 +0000 (03:27 +0000)
committerMichael Brown <mcb30@etherboot.org>
Fri, 12 Jan 2007 03:27:05 +0000 (03:27 +0000)
src/tests/emalloc_test.c [new file with mode: 0644]

diff --git a/src/tests/emalloc_test.c b/src/tests/emalloc_test.c
new file mode 100644 (file)
index 0000000..e8428f5
--- /dev/null
@@ -0,0 +1,26 @@
+#include <vsprintf.h>
+#include <gpxe/uaccess.h>
+#include <gpxe/emalloc.h>
+#include <gpxe/memmap.h>
+
+void emalloc_test ( void ) {
+       struct memory_map memmap;
+       userptr_t bob;
+       userptr_t fred;
+
+       printf ( "Before allocation:\n" );
+       get_memmap ( &memmap );
+
+       bob = emalloc ( 1234 );
+       bob = erealloc ( bob, 12345 );
+       fred = emalloc ( 999 );
+
+       printf ( "After allocation:\n" );
+       get_memmap ( &memmap );
+
+       efree ( bob );
+       efree ( fred );
+
+       printf ( "After freeing:\n" );
+       get_memmap ( &memmap );
+}