Use the mmap/munmap for allocation routines.
To avoid any issues calling malloc related routines, use mmap/munmap. Specifically, this avoids any problems when this is compiled into a malloc debug shared library. Change-Id: Iae2d197145da43dc103ad6024357d8cc2374378f
This commit is contained in:
parent
d18b87f38d
commit
6425327c32
@ -29,14 +29,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.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"
|
#include "debug_mapinfo.h"
|
||||||
|
|
||||||
// 6f000000-6f01e000 rwxp 00000000 00:0c 16389419 /system/lib/libcomposer.so
|
// 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 (len < 50) return 0;
|
||||||
if (line[20] != 'x') return 0;
|
if (line[20] != 'x') return 0;
|
||||||
|
|
||||||
mapinfo_t* mi = static_cast<mapinfo_t*>(Malloc(malloc)(sizeof(mapinfo_t) + (len - 47)));
|
mapinfo_t* mi = static_cast<mapinfo_t*>(
|
||||||
if (mi == 0) return 0;
|
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->start = strtoul(line, 0, 16);
|
||||||
mi->end = strtoul(line + 9, 0, 16);
|
mi->end = strtoul(line + 9, 0, 16);
|
||||||
@ -85,7 +80,7 @@ __LIBC_HIDDEN__ void mapinfo_destroy(mapinfo_t* mi) {
|
|||||||
while (mi != NULL) {
|
while (mi != NULL) {
|
||||||
mapinfo_t* del = mi;
|
mapinfo_t* del = mi;
|
||||||
mi = mi->next;
|
mi = mi->next;
|
||||||
Malloc(free)(del);
|
munmap(del, sizeof(mapinfo_t) + strlen(del->name) + 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user