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


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Thu Apr 15 2021 05:07:46