advanced.cpp
Go to the documentation of this file.
1 /*
2  * LibraryHacks.cpp
3  *
4  * Created on: 23 Jan 2011
5  * Author: Andy
6  */
7 
8 #include <cstdlib>
9 #include <sys/types.h>
10 
11 
12 /*
13  * The default pulls in 70K of garbage
14  */
15 
16 namespace __gnu_cxx {
17 
19  for(;;);
20  }
21 }
22 
23 
24 /*
25  * The default pulls in about 12K of garbage
26  */
27 
28 extern "C" void __cxa_pure_virtual() {
29  for(;;);
30 }
31 
32 
33 /*
34  * Implement C++ new/delete operators using the heap
35  */
36 
37 void *operator new(size_t size) {
38  return malloc(size);
39 }
40 
41 void *operator new[](size_t size) {
42  return malloc(size);
43 }
44 
45 void operator delete(void *p) {
46  free(p);
47 }
48 
49 void operator delete[](void *p) {
50  free(p);
51 }
52 
53 
54 /*
55  * sbrk function for getting space for malloc and friends
56  */
57 
58 extern int _end;
59 
60 extern "C" {
61  caddr_t _sbrk ( int incr ) {
62 
63  static unsigned char *heap = NULL;
64  unsigned char *prev_heap;
65 
66  if (heap == NULL) {
67  heap = (unsigned char *)&_end;
68  }
69  prev_heap = heap;
70  /* check removed to show basic approach */
71 
72  heap += incr;
73 
74  return (caddr_t) prev_heap;
75  }
76 }
int _end
void __cxa_pure_virtual()
Definition: advanced.cpp:28
#define NULL
Definition: usbd_def.h:50
void __verbose_terminate_handler()
Definition: advanced.cpp:18
caddr_t _sbrk(int incr)
Definition: advanced.cpp:61


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Oct 24 2019 03:17:18