From d73c19e488121790635c2ede1afc0a217b7e8b29 Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Fri, 30 Mar 2012 12:45:33 +0100 Subject: core: Partial revert of commit 9333426b and unify lmalloc() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- 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 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 #include -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) -- cgit v1.2.1