diff options
author | Matt Fleming <matt.fleming@intel.com> | 2012-03-30 12:45:33 +0100 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2012-04-17 10:57:13 +0100 |
commit | d73c19e488121790635c2ede1afc0a217b7e8b29 (patch) | |
tree | 02befa15eb2a6c70d15db4a26789c8b234a83050 | |
parent | 81eccba80e68d637197816d15659bd30425b5f13 (diff) | |
download | syslinux-d73c19e488121790635c2ede1afc0a217b7e8b29.tar.gz syslinux-d73c19e488121790635c2ede1afc0a217b7e8b29.tar.xz syslinux-d73c19e488121790635c2ede1afc0a217b7e8b29.zip |
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@intel.com>
-rw-r--r-- | com32/include/com32.h | 2 | ||||
-rw-r--r-- | com32/lib/lmalloc.c | 9 | ||||
-rw-r--r-- | com32/lib/lstrdup.c | 2 | ||||
-rw-r--r-- | 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 f49f9eab..6b142082 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 9d532c80..3e69ac1d 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 6747ef3a..d11efe7e 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 d27fc270..fa1d26a7 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) |