Make operator new / delete weak

so you can implement your own, e.g. if you need a throwing operator new.
This commit is contained in:
Joost Nieuwenhuijse 2018-05-16 17:56:15 +02:00
parent 233f9a6a31
commit 2985d1d11e

View file

@ -4,22 +4,22 @@
#include <stdio.h>
#include <stdlib.h>
void *operator new(size_t size)
void * __attribute__((weak)) operator new(size_t size)
{
return malloc(size);
}
void *operator new[](size_t size)
void * __attribute__((weak)) operator new[](size_t size)
{
return malloc(size);
}
void operator delete(void * ptr)
void __attribute__((weak)) operator delete(void * ptr)
{
free(ptr);
}
void operator delete[](void * ptr)
void __attribute__((weak)) operator delete[](void * ptr)
{
free(ptr);
}