summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2014-07-18 22:05:48 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-07-17 22:33:54 +0000
commit3c2b71ad5612721c7073a4396cdad2c00e86ba54 (patch)
tree89601d76e7adb7fa4e2629444d9318068825bcc1
parentd18b87f38de8644acdcd1a112bd06d3a70d2ea1d (diff)
parent6425327c3278137d153b8a7505f97d2f5f058d49 (diff)
downloadbionic-3c2b71ad5612721c7073a4396cdad2c00e86ba54.zip
bionic-3c2b71ad5612721c7073a4396cdad2c00e86ba54.tar.gz
bionic-3c2b71ad5612721c7073a4396cdad2c00e86ba54.tar.bz2
Merge "Use the mmap/munmap for allocation routines."
-rw-r--r--libc/bionic/debug_mapinfo.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/libc/bionic/debug_mapinfo.cpp b/libc/bionic/debug_mapinfo.cpp
index e81ea54..17276ce 100644
--- a/libc/bionic/debug_mapinfo.cpp
+++ b/libc/bionic/debug_mapinfo.cpp
@@ -29,14 +29,8 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <sys/mman.h>
-#ifdef USE_JEMALLOC
-#include "jemalloc.h"
-#define Malloc(function) je_ ## function
-#else
-#include "dlmalloc.h"
-#define Malloc(function) dl ## function
-#endif
#include "debug_mapinfo.h"
// 6f000000-6f01e000 rwxp 00000000 00:0c 16389419 /system/lib/libcomposer.so
@@ -52,8 +46,9 @@ static mapinfo_t* parse_maps_line(char* line) {
if (len < 50) return 0;
if (line[20] != 'x') return 0;
- mapinfo_t* mi = static_cast<mapinfo_t*>(Malloc(malloc)(sizeof(mapinfo_t) + (len - 47)));
- if (mi == 0) return 0;
+ mapinfo_t* mi = static_cast<mapinfo_t*>(
+ mmap(NULL, sizeof(mapinfo_t) + (len - 47), PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0));
+ if (mi == MAP_FAILED) return 0;
mi->start = strtoul(line, 0, 16);
mi->end = strtoul(line + 9, 0, 16);
@@ -85,7 +80,7 @@ __LIBC_HIDDEN__ void mapinfo_destroy(mapinfo_t* mi) {
while (mi != NULL) {
mapinfo_t* del = mi;
mi = mi->next;
- Malloc(free)(del);
+ munmap(del, sizeof(mapinfo_t) + strlen(del->name) + 2);
}
}