2019-06-20 02:26:12 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <mimalloc.h>
|
2019-07-19 05:52:29 +03:00
|
|
|
#include <mimalloc-override.h>
|
2019-06-20 02:26:12 +03:00
|
|
|
|
2019-07-15 05:56:33 +03:00
|
|
|
#include <new>
|
|
|
|
|
2019-06-20 02:26:12 +03:00
|
|
|
static void* p = malloc(8);
|
|
|
|
|
|
|
|
void free_p() {
|
|
|
|
free(p);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-04 19:29:33 +03:00
|
|
|
class Test {
|
|
|
|
private:
|
|
|
|
int i;
|
|
|
|
public:
|
|
|
|
Test(int x) { i = x; }
|
|
|
|
~Test() { }
|
|
|
|
};
|
|
|
|
|
2019-07-19 04:59:32 +03:00
|
|
|
|
|
|
|
int main() {
|
|
|
|
//mi_malloc_override();
|
|
|
|
mi_stats_reset();
|
2019-06-20 02:26:12 +03:00
|
|
|
atexit(free_p);
|
|
|
|
void* p1 = malloc(78);
|
2019-07-19 04:59:32 +03:00
|
|
|
void* p2 = _aligned_malloc(24,16);
|
2019-06-20 02:26:12 +03:00
|
|
|
free(p1);
|
|
|
|
p1 = malloc(8);
|
2019-07-19 04:59:32 +03:00
|
|
|
char* s = _strdup("hello\n");
|
|
|
|
_aligned_free(p2);
|
2019-06-20 02:26:12 +03:00
|
|
|
p2 = malloc(16);
|
|
|
|
p1 = realloc(p1, 32);
|
|
|
|
free(p1);
|
|
|
|
free(p2);
|
|
|
|
free(s);
|
2019-07-04 19:29:33 +03:00
|
|
|
Test* t = new Test(42);
|
|
|
|
delete t;
|
2019-07-15 05:56:33 +03:00
|
|
|
t = new (std::nothrow) Test(42);
|
|
|
|
delete t;
|
2019-07-19 05:52:29 +03:00
|
|
|
return 0;
|
2019-06-20 02:26:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
class Static {
|
|
|
|
private:
|
|
|
|
void* p;
|
|
|
|
public:
|
|
|
|
Static() {
|
|
|
|
p = malloc(64);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
~Static() {
|
|
|
|
free(p);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static Static s = Static();
|