allocator delete checks
This commit is contained in:
parent
fbaa89d342
commit
6c05ee0e82
|
@ -106,13 +106,13 @@ static void addr2line(void *address, const char* name, bool viewSource = false)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void printBacktrace()
|
void printBacktrace(int skips)
|
||||||
{
|
{
|
||||||
void *buffer[128];
|
void *buffer[128];
|
||||||
int size = backtrace(buffer, 128);
|
int size = backtrace(buffer, 128);
|
||||||
char **strings = backtrace_symbols(buffer, size);
|
char **strings = backtrace_symbols(buffer, size);
|
||||||
for(int i = 1; i < size; i++) {
|
for(int i = 1 + skips; i < size; i++) {
|
||||||
if(i == 1) {
|
if(i == 1 + skips) {
|
||||||
printf("\tfrom ");
|
printf("\tfrom ");
|
||||||
} else {
|
} else {
|
||||||
printf("\tat ");
|
printf("\tat ");
|
||||||
|
@ -277,7 +277,7 @@ void Allocator::deallocate(void *p)
|
||||||
disableAllocator();
|
disableAllocator();
|
||||||
|
|
||||||
printf("attempt to delete NULL address\n");
|
printf("attempt to delete NULL address\n");
|
||||||
printBacktrace();
|
printBacktrace(1);
|
||||||
|
|
||||||
enableAllocator();
|
enableAllocator();
|
||||||
} else {
|
} else {
|
||||||
|
@ -293,7 +293,7 @@ void Allocator::deallocate(void *p)
|
||||||
free(p);
|
free(p);
|
||||||
} else {
|
} else {
|
||||||
printf("invalid delete address\n");
|
printf("invalid delete address\n");
|
||||||
printBacktrace();
|
printBacktrace(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
enableAllocator();
|
enableAllocator();
|
||||||
|
|
Loading…
Reference in New Issue