[syslinux:elflink] elflink: differentiate the 2 malloc system

syslinux-bot for Feng Tang feng.tang at intel.com
Thu Aug 12 21:03:11 PDT 2010


Commit-ID:  9aebffe8214587cf425650834e71329f12f13ba7
Gitweb:     http://syslinux.zytor.com/commit/9aebffe8214587cf425650834e71329f12f13ba7
Author:     Feng Tang <feng.tang at intel.com>
AuthorDate: Tue, 8 Jun 2010 15:37:49 +0800
Committer:  Feng Tang <feng.tang at intel.com>
CommitDate: Tue, 20 Jul 2010 11:10:03 +0800

elflink: differentiate the 2 malloc system

core and com32 both have their own malloc system, change the name
to make them co-exist


---
 core/fs/ext2/ext2.c       |    2 +-
 core/fs/fat/fat.c         |    2 +-
 core/fs/fs.c              |    2 +-
 core/fs/iso9660/iso9660.c |    2 +-
 core/include/core.h       |    2 +-
 core/mem/free.c           |    6 +++---
 core/mem/init.c           |    4 ++--
 core/mem/malloc.c         |    4 ++--
 core/mem/malloc.h         |    2 +-
 9 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/core/fs/ext2/ext2.c b/core/fs/ext2/ext2.c
index 716670c..cf5aaa1 100644
--- a/core/fs/ext2/ext2.c
+++ b/core/fs/ext2/ext2.c
@@ -280,7 +280,7 @@ static int ext2_fs_init(struct fs_info *fs)
     if (sb.s_magic != EXT2_SUPER_MAGIC)
 	return -1;
 
-    sbi = malloc(sizeof(*sbi));
+    sbi = hmalloc(sizeof(*sbi));
     if (!sbi) {
 	malloc_error("ext2_sb_info structure");
 	return -1;
diff --git a/core/fs/fat/fat.c b/core/fs/fat/fat.c
index a21f431..cbcd051 100644
--- a/core/fs/fat/fat.c
+++ b/core/fs/fat/fat.c
@@ -754,7 +754,7 @@ static int vfat_fs_init(struct fs_info *fs)
     /* XXX: Find better sanity checks... */
     if (!fat.bxResSectors || !fat.bxFATs)
 	return -1;
-    sbi = malloc(sizeof(*sbi));
+    sbi = hmalloc(sizeof(*sbi));
     if (!sbi)
 	malloc_error("fat_sb_info structure");
     fs->fs_info = sbi;
diff --git a/core/fs/fs.c b/core/fs/fs.c
index 3ae12ec..058a762 100644
--- a/core/fs/fs.c
+++ b/core/fs/fs.c
@@ -250,7 +250,7 @@ int searchdir(const char *name)
 			total_len > MAX_SYMLINK_BUF)
 			goto err;
 
-		    linkbuf = malloc(total_len);
+		    linkbuf = hmalloc(total_len);
 		    if (!linkbuf)
 			goto err;
 
diff --git a/core/fs/iso9660/iso9660.c b/core/fs/iso9660/iso9660.c
index d695e43..428e0cd 100644
--- a/core/fs/iso9660/iso9660.c
+++ b/core/fs/iso9660/iso9660.c
@@ -307,7 +307,7 @@ static int iso_fs_init(struct fs_info *fs)
     struct disk *disk = fs->fs_dev->disk;
     int blktosec;
 
-    sbi = malloc(sizeof(*sbi));
+    sbi = hmalloc(sizeof(*sbi));
     if (!sbi) {
 	malloc_error("iso_sb_info structure");
 	return 1;
diff --git a/core/include/core.h b/core/include/core.h
index eb7bfcd..f4c8586 100644
--- a/core/include/core.h
+++ b/core/include/core.h
@@ -30,7 +30,7 @@ extern void __idle(void);
 extern void reset_idle(void);
 
 /* mem/malloc.c, mem/free.c, mem/init.c */
-extern void *malloc(size_t);
+extern void *hmalloc(size_t);
 extern void *lmalloc(size_t);
 extern void *pmapi_lmalloc(size_t);
 extern void *zalloc(size_t);
diff --git a/core/mem/free.c b/core/mem/free.c
index 0becb9e..09d08c1 100644
--- a/core/mem/free.c
+++ b/core/mem/free.c
@@ -13,7 +13,7 @@ __free_block(struct free_arena_header *ah)
 {
     struct free_arena_header *pah, *nah;
     struct free_arena_header *head =
-	&__malloc_head[ARENA_HEAP_GET(ah->a.attrs)];
+	&__core_malloc_head[ARENA_HEAP_GET(ah->a.attrs)];
 
     pah = ah->a.prev;
     nah = ah->a.next;
@@ -93,7 +93,7 @@ void free(void *ptr)
 void __inject_free_block(struct free_arena_header *ah)
 {
     struct free_arena_header *head =
-	&__malloc_head[ARENA_HEAP_GET(ah->a.attrs)];
+	&__core_malloc_head[ARENA_HEAP_GET(ah->a.attrs)];
     struct free_arena_header *nah;
     size_t a_end = (size_t) ah + ARENA_SIZE_GET(ah->a.attrs);
     size_t n_end;
@@ -135,7 +135,7 @@ static void __free_tagged(malloc_tag_t tag) {
 
     for (i = 0; i < NHEAP; i++) {
 	dprintf("__free_tagged(%u) heap %d\n", tag, i);
-	head = &__malloc_head[i];
+	head = &__core_malloc_head[i];
 	for (fp = head ; fp != head ; fp = fp->a.next) {
 	    if (ARENA_TYPE_GET(fp->a.attrs) == ARENA_TYPE_USED &&
 		fp->a.tag == tag)
diff --git a/core/mem/init.c b/core/mem/init.c
index 487bbb3..ce9bd1b 100644
--- a/core/mem/init.c
+++ b/core/mem/init.c
@@ -3,7 +3,7 @@
 #include <string.h>
 #include "malloc.h"
 
-struct free_arena_header __malloc_head[NHEAP];
+struct free_arena_header __core_malloc_head[NHEAP];
 
 static __hugebss char main_heap[128 << 10];
 extern char __lowmem_heap[];
@@ -16,7 +16,7 @@ void mem_init(void)
 
     /* Initialize the head nodes */
 
-    fp = &__malloc_head[0];
+    fp = &__core_malloc_head[0];
     for (i = 0 ; i < NHEAP ; i++) {
 	fp->a.next = fp->a.prev = fp->next_free = fp->prev_free = fp;
 	fp->a.attrs = ARENA_TYPE_HEAD | (i << ARENA_HEAP_POS);
diff --git a/core/mem/malloc.c b/core/mem/malloc.c
index 78f7b41..b6953ad 100644
--- a/core/mem/malloc.c
+++ b/core/mem/malloc.c
@@ -60,7 +60,7 @@ static void *__malloc_from_block(struct free_arena_header *fp,
 static void *_malloc(size_t size, enum heap heap, malloc_tag_t tag)
 {
     struct free_arena_header *fp;
-    struct free_arena_header *head = &__malloc_head[heap];
+    struct free_arena_header *head = &__core_malloc_head[heap];
     void *p = NULL;
 
     dprintf("_malloc(%zu, %u, %u) @ %p = ",
@@ -83,7 +83,7 @@ static void *_malloc(size_t size, enum heap heap, malloc_tag_t tag)
     return p;
 }
 
-void *malloc(size_t size)
+void *hmalloc(size_t size)
 {
     return _malloc(size, HEAP_MAIN, MALLOC_CORE);
 }
diff --git a/core/mem/malloc.h b/core/mem/malloc.h
index b8ec44d..8791349 100644
--- a/core/mem/malloc.h
+++ b/core/mem/malloc.h
@@ -78,5 +78,5 @@ struct free_arena_header {
     size_t _pad[2];		/* Pad to 2*sizeof(struct arena_header) */
 };
 
-extern struct free_arena_header __malloc_head[NHEAP];
+extern struct free_arena_header __core_malloc_head[NHEAP];
 void __inject_free_block(struct free_arena_header *ah);



More information about the Syslinux-commits mailing list