Mirror with some correction
Dependencies: mbed FastIO FastPWM USBDevice
NewMalloc/OpNew.cpp@116:7a67265d7c19, 2021-10-01 (annotated)
- Committer:
- arnoz
- Date:
- Fri Oct 01 08:19:46 2021 +0000
- Revision:
- 116:7a67265d7c19
- Parent:
- 79:682ae3171a08
- Correct information regarding your last merge
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mjr | 79:682ae3171a08 | 1 | #include "NewMalloc.h" |
mjr | 79:682ae3171a08 | 2 | |
mjr | 79:682ae3171a08 | 3 | // Overload operator new to call our custom malloc. This ensures that |
mjr | 79:682ae3171a08 | 4 | // all 'new' allocations throughout the program (including library code) |
mjr | 79:682ae3171a08 | 5 | // go through our private allocator. |
mjr | 79:682ae3171a08 | 6 | void *operator new(size_t siz) { return xmalloc(siz); } |
mjr | 79:682ae3171a08 | 7 | void *operator new[](size_t siz) { return xmalloc(siz); } |
mjr | 79:682ae3171a08 | 8 | |
mjr | 79:682ae3171a08 | 9 | // Since we don't do bookkeeping to track released memory, 'delete' does |
mjr | 79:682ae3171a08 | 10 | // nothing. In actual testing, this routine appears to never be called. |
mjr | 79:682ae3171a08 | 11 | // If it *is* ever called, it will simply leave the block in place, which |
mjr | 79:682ae3171a08 | 12 | // will make it unavailable for re-use but will otherwise be harmless. |
mjr | 79:682ae3171a08 | 13 | void operator delete(void *ptr) { } |