about summary refs log tree commit diff stats
path: root/src/wrapped/wrappedlibpcre.c
blob: 98581aa9010d8244f9dbc43e315175c29b6e91c0 (plain) (blame)
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE         /* See feature_test_macros(7) */
#include <dlfcn.h>

#include "wrappedlibs.h"

#include "wrapper.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "x64emu.h"
#include "callback.h"
#include "debug.h"

const char* libpcreName = "libpcre.so.3";
#define LIBNAME libpcre

typedef void  (*pcre_free_t)(void *);
EXPORT uintptr_t my_pcre_free;

void wrapped_pcre_free(void* p) {
    if(my_pcre_free)
        RunFunctionFmt(my_pcre_free, "p", p);
    else
        box_free(p);
}
EXPORT pcre_free_t pcre_free = wrapped_pcre_free;

#define CUSTOM_INIT \
    my_pcre_free = AddCheckBridge(lib->w.bridge, vFp, free, 0, "free");

#include "wrappedlib_init.h"