Try to memcheck

This commit is contained in:
PolynomialDivision 2017-08-31 11:27:45 +02:00
parent d055d29f23
commit a0b38a3f31

View file

@ -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;