(and spent 8 bytes too much per malloc)
* if the memory allocator detects freelist corruption, print a message
instead of silently dying.
Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Jordan Crouse <jordan.crouse@amd.com>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3510
2b7e53f0-3cfb-0310-b3e9-
8179ed1497e1
header = *((hdrtype_t *) ptr);
int size = SIZE(header);
- if (!HAS_MAGIC(header) || size == 0)
+ if (!HAS_MAGIC(header) || size == 0) {
+ printf("memory allocator panic.\n");
halt();
+ }
if (header & FLAG_FREE) {
if (len <= size) {
void *nptr = ptr + (HDRSIZE + len);
- int nsize = size - (len + 8);
+ int nsize = size - (HDRSIZE + len);
/* Mark the block as used. */
*((hdrtype_t *) ptr) = USED_BLOCK(len);
if (nsize > 0)
*((hdrtype_t *) nptr) =
- FREE_BLOCK(nsize - 4);
+ FREE_BLOCK(nsize);
return (void *)(ptr + HDRSIZE);
}