aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tlsf.c14
-rw-r--r--src/tlsf.h2
2 files changed, 10 insertions, 6 deletions
diff --git a/src/tlsf.c b/src/tlsf.c
index 97a1410..199e143 100644
--- a/src/tlsf.c
+++ b/src/tlsf.c
@@ -1,5 +1,5 @@
/* Two Levels Segregate Fit memory allocator (TLSF)
- * Version 2.4.4
+ * Version 2.4.6
*
* Modified for Tuplr by David Robillard.
* Original TLSF code available at http://rtportal.upv.es/rtmalloc/
@@ -95,7 +95,6 @@
#define PAGE_SIZE (sysconf(_SC_PAGESIZE))
#endif
-#define PRINT_MSG(fmt, args...) printf(fmt, ## args)
#define ERROR_MSG(fmt, args...) printf(fmt, ## args)
typedef struct free_ptr_s {
@@ -322,6 +321,9 @@ get_new_area(size_t * size)
#endif
#ifdef USE_MMAP
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS MAP_ANON
+#endif
*size = ROUNDUP(*size, PAGE_SIZE);
if ((area = mmap(0, *size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0)) != MAP_FAILED)
return area;
@@ -364,12 +366,12 @@ tlsf_init(void* area, size_t area_size)
bhdr_t *b, *ib;
if (!area || !area_size || area_size < sizeof(tlsf_t) + BHDR_OVERHEAD * 8) {
- ERROR_MSG("init_memory_pool (): memory_pool invalid\n");
+ ERROR_MSG("memory pool invalid\n");
return NULL;
}
if (((unsigned long) area & PTR_MASK)) {
- ERROR_MSG("init_memory_pool (): area must be aligned to a word\n");
+ ERROR_MSG("memory pool area must be aligned to a word\n");
return NULL;
}
tlsf = (tlsf_t *) area;
@@ -662,7 +664,9 @@ tlsf_realloc(tlsf_t* tlsf, void* ptr, size_t new_size)
}
}
- ptr_aux = tlsf_malloc(tlsf, new_size);
+ if (!(ptr_aux = tlsf_malloc(tlsf, new_size))) {
+ return NULL;
+ }
cpsize = ((b->size & BLOCK_SIZE) > new_size) ? new_size : (b->size & BLOCK_SIZE);
diff --git a/src/tlsf.h b/src/tlsf.h
index 35d5f97..1f987ce 100644
--- a/src/tlsf.h
+++ b/src/tlsf.h
@@ -1,5 +1,5 @@
/* Two Levels Segregate Fit memory allocator (TLSF)
- * Version 2.4.4
+ * Version 2.4.6
*
* Modified for Tuplr by David Robillard.
* Original TLSF code available at http://rtportal.upv.es/rtmalloc/