mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
Try to memcheck
This commit is contained in:
parent
d055d29f23
commit
a0b38a3f31
1 changed files with 28 additions and 0 deletions
28
src/main.c
28
src/main.c
|
@ -12,6 +12,34 @@
|
|||
|
||||
#include "crypto.h"
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
static void* (*real_malloc)(size_t)=NULL;
|
||||
|
||||
static void mtrace_init(void)
|
||||
{
|
||||
real_malloc = dlsym(RTLD_NEXT, "malloc");
|
||||
if (NULL == real_malloc) {
|
||||
fprintf(stderr, "Error in `dlsym`: %s\n", dlerror());
|
||||
}
|
||||
}
|
||||
|
||||
void *malloc(size_t size)
|
||||
{
|
||||
mtrace_init();
|
||||
if(real_malloc==NULL) {
|
||||
mtrace_init();
|
||||
}
|
||||
|
||||
void *p = NULL;
|
||||
fprintf(stderr, "malloc(%d) = ", size);
|
||||
p = real_malloc(size);
|
||||
fprintf(stderr, "%p\n", p);
|
||||
return p;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
const char *ubus_socket = NULL;
|
||||
int ch;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue