mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-07-06 19:38:41 +03:00
wip: track allocation locations in debug mode
This commit is contained in:
parent
4090561975
commit
21a95c7449
10 changed files with 257 additions and 141 deletions
|
@ -4,7 +4,9 @@
|
|||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <mimalloc-new-delete.h>
|
||||
#include <mimalloc.h>
|
||||
#include <mimalloc-override.h>
|
||||
#include <new>
|
||||
#include <vector>
|
||||
|
||||
|
@ -57,8 +59,16 @@ int main() {
|
|||
|
||||
static void dangling_ptr_write() {
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
uint8_t* p = new uint8_t[16];
|
||||
free(p);
|
||||
uint8_t* p;
|
||||
if ((i & 1) == 0) {
|
||||
p = (uint8_t*)malloc(16);
|
||||
free(p);
|
||||
}
|
||||
else {
|
||||
p = new uint8_t[16];
|
||||
// delete p; // delete sets the pointer to an invalid value generally
|
||||
free(p);
|
||||
}
|
||||
p[0] = 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue