1#ifndef CPP_H 2#define CPP_H 3/* cpp - C++ in the kernel 4** 5** Initial version by Axel Dörfler, axeld@pinc-software.de 6** This file may be used under the terms of the OpenBeOS License. 7*/ 8 9#ifdef __cplusplus 10 11#include <new> 12#include <stdlib.h> 13 14 15// Oh no! C++ in the kernel! Are you nuts? 16// 17// - no exceptions 18// - (almost) no virtuals (well, the Query code now uses them) 19// - it's basically only the C++ syntax, and type checking 20// - since one tend to encapsulate everything in classes, it has a slightly 21// higher memory overhead 22// - nicer code 23// - easier to maintain 24 25 26inline void *operator new(size_t size, const nothrow_t&) throw() 27{ 28 return malloc(size); 29} 30 31inline void *operator new[](size_t size, const nothrow_t&) throw() 32{ 33 return malloc(size); 34} 35 36inline void operator delete(void *ptr) 37{ 38 free(ptr); 39} 40 41inline void operator delete[](void *ptr) 42{ 43 free(ptr); 44} 45 46// now we're using virtuals 47extern "C" void __pure_virtual(); 48 49#endif // __cplusplus 50 51#endif /* CPP_H */ 52