-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLAssert_alloc.c
More file actions
38 lines (32 loc) · 887 Bytes
/
LAssert_alloc.c
File metadata and controls
38 lines (32 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdlib.h>
extern void *__libc_malloc(size_t size);
extern void *__libc_calloc(size_t nmemb, size_t size);
extern void *__libc_realloc(void * ptr, size_t size);
extern void *__libc_reallocarray(void * ptr, size_t nmemb, size_t size);
int _lassert_malloc_lock = 0;
void * malloc(size_t size){
if(_lassert_malloc_lock){
return NULL;
}
return __libc_malloc(size);
}
void * calloc(size_t nmemb, size_t size){
if(_lassert_malloc_lock){
return NULL;
}
return __libc_calloc(nmemb, size);
}
void * realloc(void * ptr, size_t size){
if(_lassert_malloc_lock){
return NULL;
}
return __libc_realloc(ptr, size);
}
#ifdef _GNU_SOURCE
void * reallocarray(void * ptr, size_t nmemb, size_t size){
if(_lassert_malloc_lock){
return NULL;
}
return __libc_reallocarray(ptr, nmemb, size);
}
#endif