summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoranonymous <local@localhost>2010-08-28 14:57:18 +0700
committeranonymous <local@localhost>2010-08-28 14:57:18 +0700
commita0513e59969b98c1f807b8317b7e556b7af16ab2 (patch)
tree3d50bf26b09ba92ef83fb51d6c08a079d6c8eff4 /src
parent5dba426b4ca83f783a1487c5684f6a84351d4686 (diff)
downloadlibcxxrt-a0513e59969b98c1f807b8317b7e556b7af16ab2.tar.gz
libcxxrt-a0513e59969b98c1f807b8317b7e556b7af16ab2.tar.bz2
libcxxrt-a0513e59969b98c1f807b8317b7e556b7af16ab2.tar.xz
set_new_handler was implemented
Diffstat (limited to 'src')
-rw-r--r--src/memory.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/memory.cc b/src/memory.cc
index 0c4ad3b..8e5574a 100644
--- a/src/memory.cc
+++ b/src/memory.cc
@@ -7,11 +7,30 @@
#include <malloc.h>
#include "stdexcept.h"
+namespace std {
+ void terminate();
+}
+
+typedef void (*new_handler)();
+static new_handler new_handl = &std::terminate;
+
+
+namespace std {
+ new_handler set_new_handler(new_handler handl) {
+ new_handler old = new_handl;
+ new_handl = handl;
+ return old;
+ }
+}
+
+
__attribute__((weak))
void * operator new(size_t size) {
+
void * mem = malloc(size);
- if(mem == NULL) {
- throw std::bad_alloc();
+ while(mem == NULL) {
+ new_handl();
+ mem = malloc(size);
}
return mem;