aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;
}