blob: 6a8e03ebe55940305a595722c8ea95be7071978b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include <unistd.h>
extern "C" void* emulate_cc_new(unsigned long len) { \
void *p = malloc(len);
if (p == 0) {
/* Don't use stdio (e.g. fputs), because that may want to allocate more
* memory.
*/
(void)!write(2, "out of memory\n", 14);
abort();
}
return p;
}
extern "C" void emulate_cc_delete(void* p) {
if (p != 0)
free(p);
}
extern "C" void emulate_cc_delete2(void* p, unsigned long len) {
if (p != 0)
free(p);
}
void* operator new (unsigned long) __attribute__((alias("emulate_cc_new")));
void* operator new[](unsigned long) __attribute__((alias("emulate_cc_new")));
void operator delete (void* p) __attribute__((alias("emulate_cc_delete")));
void operator delete[](void* p) __attribute__((alias("emulate_cc_delete")));
void operator delete (void* p, unsigned long len) __attribute__((alias("emulate_cc_delete2")));
void operator delete[](void* p, unsigned long len) __attribute__((alias("emulate_cc_delete2")));
void* __cxa_pure_virtual = 0;
|