-
Notifications
You must be signed in to change notification settings - Fork 6
/
mnew.cc
25 lines (23 loc) · 846 Bytes
/
mnew.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <sys/types.h>
#include <sys/cdefs.h>
#include <new>
extern "C" {
void *malloc(size_t s);
void free(void *p);
}
void * operator new(size_t size) throw (std::bad_alloc) {
void *ret = malloc(size);
if (!ret) throw std::bad_alloc();
return ret;
}
void operator delete(void *p) __THROW { free(p); }
void * operator new[](size_t size) throw (std::bad_alloc) {
void *ret = malloc(size);
if (!ret) throw std::bad_alloc();
return ret;
}
void operator delete[](void *p) __THROW { free(p); }
void* operator new(size_t size, const std::nothrow_t& nt) __THROW {return malloc(size); }
void* operator new[](size_t size, const std::nothrow_t& nt) __THROW {return malloc(size);}
void operator delete(void *ptr, const std::nothrow_t& nt) __THROW {free(ptr);}
void operator delete[](void *ptr, const std::nothrow_t& nt) __THROW {free(ptr);}