aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib/free.c
diff options
context:
space:
mode:
authorStefan Bucur <stefanb@zytor.com>2008-08-14 01:02:46 +0300
committerStefan Bucur <stefan@stefan-ubumac.(none)>2009-03-15 10:10:51 +0200
commit3d43756af624dffa27986308dadd0b6acdf99eed (patch)
tree7804d7b38a0032e6df3cf5447c4e614ffb21505c /com32/lib/free.c
parent1ed26aae0dd31768f6abc7634332eae2d5085f06 (diff)
downloadsyslinux-elf-3d43756af624dffa27986308dadd0b6acdf99eed.tar.gz
syslinux-elf-3d43756af624dffa27986308dadd0b6acdf99eed.tar.xz
syslinux-elf-3d43756af624dffa27986308dadd0b6acdf99eed.zip
Made room in the arena_header structure for custom data.
Diffstat (limited to 'com32/lib/free.c')
-rw-r--r--com32/lib/free.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/com32/lib/free.c b/com32/lib/free.c
index aa17080d..0cf874b4 100644
--- a/com32/lib/free.c
+++ b/com32/lib/free.c
@@ -14,22 +14,23 @@ __free_block(struct free_arena_header *ah)
pah = ah->a.prev;
nah = ah->a.next;
- if ( pah->a.type == ARENA_TYPE_FREE &&
- (char *)pah+pah->a.size == (char *)ah ) {
+ if ( ARENA_TYPE_GET(pah->a.attrs) == ARENA_TYPE_FREE &&
+ (char *)pah+ARENA_SIZE_GET(pah->a.attrs) == (char *)ah ) {
/* Coalesce into the previous block */
- pah->a.size += ah->a.size;
+ ARENA_SIZE_SET(pah->a.attrs, ARENA_SIZE_GET(pah->a.attrs) +
+ ARENA_SIZE_GET(ah->a.attrs));
pah->a.next = nah;
nah->a.prev = pah;
#ifdef DEBUG_MALLOC
- ah->a.type = ARENA_TYPE_DEAD;
+ ARENA_TYPE_SET(ah->a.attrs, ARENA_TYPE_DEAD);
#endif
ah = pah;
pah = ah->a.prev;
} else {
/* Need to add this block to the free chain */
- ah->a.type = ARENA_TYPE_FREE;
+ ARENA_TYPE_SET(ah->a.attrs, ARENA_TYPE_FREE);
ah->next_free = __malloc_head.next_free;
ah->prev_free = &__malloc_head;
@@ -39,9 +40,10 @@ __free_block(struct free_arena_header *ah)
/* In either of the previous cases, we might be able to merge
with the subsequent block... */
- if ( nah->a.type == ARENA_TYPE_FREE &&
- (char *)ah+ah->a.size == (char *)nah ) {
- ah->a.size += nah->a.size;
+ if ( ARENA_TYPE_GET(nah->a.attrs) == ARENA_TYPE_FREE &&
+ (char *)ah+ARENA_SIZE_GET(ah->a.attrs) == (char *)nah ) {
+ ARENA_SIZE_SET(ah->a.attrs, ARENA_SIZE_GET(ah->a.attrs) +
+ ARENA_SIZE_GET(nah->a.attrs));
/* Remove the old block from the chains */
nah->next_free->prev_free = nah->prev_free;
@@ -50,7 +52,7 @@ __free_block(struct free_arena_header *ah)
nah->a.next->a.prev = ah;
#ifdef DEBUG_MALLOC
- nah->a.type = ARENA_TYPE_DEAD;
+ ARENA_TYPE_SET(nah->a.attrs, ARENA_TYPE_DEAD);
#endif
}
@@ -69,7 +71,7 @@ void free(void *ptr)
((struct arena_header *)ptr - 1);
#ifdef DEBUG_MALLOC
- assert( ah->a.type == ARENA_TYPE_USED );
+ assert( ARENA_TYPE_GET(ah->a.attrs) == ARENA_TYPE_USED );
#endif
__free_block(ah);