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


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Wed Jul 3 2019 19:59:24