summaryrefslogtreecommitdiffstats
path: root/payloads/libpayload/libc/malloc.c
diff options
context:
space:
mode:
authorPatrick Georgi <patrick.georgi@coresystems.de>2009-05-21 10:02:52 +0000
committerPatrick Georgi <patrick.georgi@coresystems.de>2009-05-21 10:02:52 +0000
commitd385ed29b94af71dedeb5f44d72ad8dab43c4664 (patch)
tree6eea529dc55d67078ac9fc0fbf271189318c4a12 /payloads/libpayload/libc/malloc.c
parent1e6f6929c1ee96b291ef17e8d801f376a5dbb0d2 (diff)
downloadcoreboot-staging-d385ed29b94af71dedeb5f44d72ad8dab43c4664.zip
coreboot-staging-d385ed29b94af71dedeb5f44d72ad8dab43c4664.tar.gz
This change adds PPC support to libpayload, and hooks it up in the build
process. The PPC support is still stubbed, with commented out x86 code as guide line for an implementor. Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de> Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4293 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'payloads/libpayload/libc/malloc.c')
-rw-r--r--payloads/libpayload/libc/malloc.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/payloads/libpayload/libc/malloc.c b/payloads/libpayload/libc/malloc.c
index 24daf0e..d18b289 100644
--- a/payloads/libpayload/libc/malloc.c
+++ b/payloads/libpayload/libc/malloc.c
@@ -103,16 +103,22 @@ static void *alloc(int len)
void *nptr = ptr + (HDRSIZE + len);
int nsize = size - (HDRSIZE + len);
- /* Mark the block as used. */
- *((hdrtype_t *) ptr) = USED_BLOCK(len);
-
/* If there is still room in this block,
- * then mark it as such.
+ * then mark it as such otherwise account
+ * the whole space for that block.
*/
- if (nsize > 0)
+ if (nsize > 0) {
+ /* Mark the block as used. */
+ *((hdrtype_t *) ptr) = USED_BLOCK(len);
+
+ /* Create a new free block. */
*((hdrtype_t *) nptr) =
FREE_BLOCK(nsize);
+ } else {
+ /* Mark the block as used. */
+ *((hdrtype_t *) ptr) = USED_BLOCK(size);
+ }
return (void *)(ptr + HDRSIZE);
}
OpenPOWER on IntegriCloud