aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-07-05 17:36:12 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-07-05 17:36:12 -0700
commit1cd5f2e5c36c6509e6d0f2a6b26165c1e933c051 (patch)
tree46a32b4765337b89bbe944c37008be903693d73f
parent5662188616aa006d48e19f431639e0db8c08da64 (diff)
downloadsyslinux-elf-core32.tar.gz
syslinux-elf-core32.tar.xz
syslinux-elf-core32.zip
malloc: inline the tag accessor functionscore32
Accessor functions are a good thing, but we can inline them to reduce the cost of accessing them. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--com32/include/stdlib.h29
-rw-r--r--com32/lib/malloc.c18
2 files changed, 23 insertions, 24 deletions
diff --git a/com32/include/stdlib.h b/com32/include/stdlib.h
index 2135569b..fad0082d 100644
--- a/com32/include/stdlib.h
+++ b/com32/include/stdlib.h
@@ -44,23 +44,30 @@ __extern int posix_memalign(void **memptr, size_t alignment,
__extern void free(void *);
+__extern void *__malloc_global_tag;
-__extern void *__mem_get_tag_global(void);
-__extern void __mem_set_tag_global(void *tag);
-
-__extern void *__mem_get_tag(void *memptr);
-__extern void __mem_set_tag(void *memptr, void *tag);
+static __inline__ void *__mem_get_tag_global(void)
+{
+ return __malloc_global_tag;
+}
-__extern void __free_tagged(void *tag);
+static __inline__ void __mem_set_tag_global(void *__tag)
+{
+ __malloc_global_tag = __tag;
+}
-static __inline__ void *__malloc_tagged(size_t size, void *tag) {
- void *result = malloc(size);
- __mem_set_tag(result, tag);
+__extern void *__mem_get_tag(void *);
+__extern void __mem_set_tag(void *, void *);
- return result;
-}
+__extern void __free_tagged(void *);
+static __inline__ void *__malloc_tagged(size_t __size, void *__tag)
+{
+ void *__result = malloc(__size);
+ __mem_set_tag(__result, __tag);
+ return __result;
+}
__extern long strtol(const char *, char **, int);
__extern long long strtoll(const char *, char **, int);
diff --git a/com32/lib/malloc.c b/com32/lib/malloc.c
index 405e6435..50359934 100644
--- a/com32/lib/malloc.c
+++ b/com32/lib/malloc.c
@@ -15,7 +15,7 @@
/**
* The global tag used to label all the new allocations
*/
-static void *__global_tag = NULL;
+void *__malloc_global_tag = NULL;
struct free_arena_header __malloc_head =
{
@@ -119,7 +119,7 @@ static void *__malloc_from_block(struct free_arena_header *fp, size_t size)
nfp->a.tag = NULL;
ARENA_TYPE_SET(fp->a.attrs, ARENA_TYPE_USED);
ARENA_SIZE_SET(fp->a.attrs, size);
- fp->a.tag = __global_tag;
+ fp->a.tag = __malloc_global_tag;
/* Insert into all-block chain */
nfp->a.prev = fp;
@@ -135,7 +135,7 @@ static void *__malloc_from_block(struct free_arena_header *fp, size_t size)
} else {
/* Allocate the whole block */
ARENA_TYPE_SET(fp->a.attrs, ARENA_TYPE_USED);
- fp->a.tag = __global_tag;
+ fp->a.tag = __malloc_global_tag;
/* Remove from free chain */
fp->next_free->prev_free = fp->prev_free;
@@ -251,20 +251,12 @@ int posix_memalign(void **memptr, size_t alignment, size_t size)
return 0;
}
-void *__mem_get_tag_global(void) {
- return __global_tag;
-}
-
-void __mem_set_tag_global(void *tag) {
- __global_tag = tag;
-}
-
void *__mem_get_tag(void *memptr) {
- struct arena_header *ah = (struct arena_header*)memptr - 1;
+ struct arena_header *ah = (struct arena_header *)memptr - 1;
return ah->tag;
}
void __mem_set_tag(void *memptr, void *tag) {
- struct arena_header *ah = (struct arena_header*)memptr - 1;
+ struct arena_header *ah = (struct arena_header *)memptr - 1;
ah->tag = tag;
}