aboutsummaryrefslogtreecommitdiff
path: root/utils/libdislocator
diff options
context:
space:
mode:
Diffstat (limited to 'utils/libdislocator')
-rw-r--r--utils/libdislocator/libdislocator.so.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/utils/libdislocator/libdislocator.so.c b/utils/libdislocator/libdislocator.so.c
index 149b910e..a6d8ecfd 100644
--- a/utils/libdislocator/libdislocator.so.c
+++ b/utils/libdislocator/libdislocator.so.c
@@ -304,7 +304,8 @@ static void *__dislocator_alloc(size_t len) {
/* The "user-facing" wrapper for calloc(). This just checks for overflows and
displays debug messages if requested. */
-void *calloc(size_t elem_len, size_t elem_cnt) {
+__attribute__((malloc)) __attribute__((alloc_size(1, 2))) void *calloc(
+ size_t elem_len, size_t elem_cnt) {
void *ret;
@@ -339,7 +340,8 @@ void *calloc(size_t elem_len, size_t elem_cnt) {
memory (unlike calloc(), malloc() is not guaranteed to return zeroed
memory). */
-void *malloc(size_t len) {
+__attribute__((malloc)) __attribute__((alloc_size(1))) void *malloc(
+ size_t len) {
void *ret;
@@ -398,7 +400,7 @@ void free(void *ptr) {
/* Realloc is pretty straightforward, too. We forcibly reallocate the buffer,
move data, and then free (aka mprotect()) the original one. */
-void *realloc(void *ptr, size_t len) {
+__attribute__((alloc_size(2))) void *realloc(void *ptr, size_t len) {
void *ret;
@@ -450,7 +452,8 @@ int posix_memalign(void **ptr, size_t align, size_t len) {
/* just the non-posix fashion */
-void *memalign(size_t align, size_t len) {
+__attribute__((malloc)) __attribute__((alloc_size(2))) void *memalign(
+ size_t align, size_t len) {
void *ret = NULL;
@@ -466,7 +469,8 @@ void *memalign(size_t align, size_t len) {
/* sort of C11 alias of memalign only more severe, alignment-wise */
-void *aligned_alloc(size_t align, size_t len) {
+__attribute__((malloc)) __attribute__((alloc_size(2))) void *aligned_alloc(
+ size_t align, size_t len) {
void *ret = NULL;
@@ -484,7 +488,8 @@ void *aligned_alloc(size_t align, size_t len) {
/* specific BSD api mainly checking possible overflow for the size */
-void *reallocarray(void *ptr, size_t elem_len, size_t elem_cnt) {
+__attribute__((alloc_size(2, 3))) void *reallocarray(void *ptr, size_t elem_len,
+ size_t elem_cnt) {
const size_t elem_lim = 1UL << (sizeof(size_t) * 4);
const size_t elem_tot = elem_len * elem_cnt;