[syslinux:elflink] core: Partial revert of commit 9333426b and unify lmalloc()

syslinux-bot for Matt Fleming matt.fleming at intel.com
Tue Apr 17 11:24:08 PDT 2012


Commit-ID:  d73c19e488121790635c2ede1afc0a217b7e8b29
Gitweb:     http://www.syslinux.org/commit/d73c19e488121790635c2ede1afc0a217b7e8b29
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Fri, 30 Mar 2012 12:45:33 +0100
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Tue, 17 Apr 2012 10:57:13 +0100

core: Partial revert of commit 9333426b and unify lmalloc()

The reason behind commit 9333426b ("elflink: fix the global naming for
lmalloc") seems to be that we need to avoid having two 'lmalloc'
symbols, one in the core and one in the com32 library.

Unfortunately, this commit introduced the following warning in
multiple places,

meminfo.c:47:2: warning: implicit declaration of function ‘lmalloc’
meminfo.c:47:9: warning: assignment makes pointer from integer without a cast
meminfo.c:93:5: warning: implicit declaration of function ‘free’
meminfo.c:93:5: warning: incompatible implicit declaration of built-in function ‘free’

Consolidate the implementations of lmalloc() so that it's suitable for
use both in the com32 library code and the core.

Signed-off-by: Matt Fleming <matt.fleming at intel.com>

---
 com32/include/com32.h |    2 +-
 com32/lib/lmalloc.c   |    9 ---------
 com32/lib/lstrdup.c   |    2 +-
 core/mem/malloc.c     |    7 ++++++-
 4 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/com32/include/com32.h b/com32/include/com32.h
index f49f9ea..6b14208 100644
--- a/com32/include/com32.h
+++ b/com32/include/com32.h
@@ -120,7 +120,7 @@ extern const com32sys_t __com32_zero_regs;
 /*
  * Lowmem allocation functions
  */
-void *clmalloc(size_t);
+void *lmalloc(size_t);
 void *lzalloc(size_t);
 void lfree(void *);
 char *lstrdup(const char *);
diff --git a/com32/lib/lmalloc.c b/com32/lib/lmalloc.c
index 9d532c8..3e69ac1 100644
--- a/com32/lib/lmalloc.c
+++ b/com32/lib/lmalloc.c
@@ -31,15 +31,6 @@
 #include <string.h>
 #include <syslinux/pmapi.h>
 
-void *clmalloc(size_t size)
-{
-    void *p;
-    p = lmalloc(size);
-    if (!p)
-	errno = ENOMEM;
-    return p;
-}
-
 void *lzalloc(size_t size)
 {
     void *p;
diff --git a/com32/lib/lstrdup.c b/com32/lib/lstrdup.c
index 6747ef3..d11efe7 100644
--- a/com32/lib/lstrdup.c
+++ b/com32/lib/lstrdup.c
@@ -9,7 +9,7 @@
 char *lstrdup(const char *s)
 {
     int l = strlen(s) + 1;
-    char *d = clmalloc(l);
+    char *d = lmalloc(l);
 
     if (d)
 	memcpy(d, s, l);
diff --git a/core/mem/malloc.c b/core/mem/malloc.c
index d27fc27..fa1d26a 100644
--- a/core/mem/malloc.c
+++ b/core/mem/malloc.c
@@ -93,7 +93,12 @@ void *malloc(size_t size)
 
 void *lmalloc(size_t size)
 {
-    return _malloc(size, HEAP_LOWMEM, MALLOC_CORE);
+    void *p;
+
+    p = _malloc(size, HEAP_LOWMEM, MALLOC_CORE);
+    if (!p)
+	errno = ENOMEM;
+    return p;
 }
 
 void *pmapi_lmalloc(size_t size)


More information about the Syslinux-commits mailing list