1 #include "scheme.h"
2 
3 #include <new>
4 
5 #ifdef USE_ATTC_PLUS_PLUS
6 #  define set_new_handler set_new_handler__FPFv_v
7 #endif
8 
9 static Object New_Handler;
10 
New_Handler_Proc()11 static void New_Handler_Proc () {
12     (void)Funcall (New_Handler, Null, 0);
13 }
14 
P_Set_New_Handler(Object p)15 static Object P_Set_New_Handler (Object p) {
16     Object old;
17 
18     Check_Procedure (p);
19     old = New_Handler;
20     New_Handler = p;
21     return old;
22 }
23 
elk_init_lib_cplusplus()24 extern "C" void elk_init_lib_cplusplus () {
25     New_Handler = Null;
26     Global_GC_Link (New_Handler);
27     std::new_handler (New_Handler_Proc);
28     Define_Primitive ((Object (*)())P_Set_New_Handler, "set-c++-new-handler!", 1, 1, EVAL);
29 }
30