Skip to content

Commit

Permalink
Merge pull request #828 from attermann/weak_allocator
Browse files Browse the repository at this point in the history
Making new/delete operators overridable
  • Loading branch information
hathach authored Jul 18, 2024
2 parents 11b6799 + cb212d0 commit 699a6c5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cores/nRF5/new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,32 @@
#include <sys/stat.h>
#include <malloc.h>

__attribute__((weak))
void *operator new(size_t size) {
return rtos_malloc(size);
}

__attribute__((weak))
void *operator new[](size_t size) {
return rtos_malloc(size);
}

__attribute__((weak))
void operator delete(void * ptr) {
rtos_free(ptr);
}

__attribute__((weak))
void operator delete[](void * ptr) {
rtos_free(ptr);
}

__attribute__((weak))
void operator delete(void * ptr, unsigned int) {
rtos_free(ptr);
}

__attribute__((weak))
void operator delete[](void * ptr, unsigned int) {
rtos_free(ptr);
}
Expand Down

0 comments on commit 699a6c5

Please sign in to comment.