Commit 1ce69297 authored by Vivek Das Mohapatra's avatar Vivek Das Mohapatra
Browse files

Capture the capsule's original free() implementation

parent 9cacbbf9
......@@ -306,6 +306,11 @@ _capsule_load (const capsule cap,
if( !ret )
goto cleanup;
// stash any free/malloc/etc implementations _before_ we overwrite them:
// (currently just free)
if( cap->ns->free == NULL )
cap->ns->free = dlsym( ret, "free" );
// TODO: failure in the dlopen fixup phase should probably be fatal:
if( ret != NULL && // no errors so far
wrappers != NULL ) // have a dlopen fixup function
......@@ -6,12 +6,17 @@
typedef void * (*dlsymfunc) (void *handle, const char *symbol);
typedef void * (*dlopnfunc) (const char *file, int flags);
// we need these to transplant the *alloc/free cluster into
// the capsule so that the memory allocation implementation
// is unified (at least until we can force libc to be shared):
typedef void (*freefunc) (void *ptr);
typedef struct _capsule_namespace
Lmid_t ns;
const char *prefix;
ptr_list *exclusions;
ptr_list *exports;
freefunc free;
char **combined_exclude;
char **combined_export;
} capsule_namespace;
......@@ -101,6 +101,7 @@ struct _capsule_metadata
const char **export;
capsule_item *items;
void *(*int_dlopen) (const char *filename, int flag);
void (*int_free) (void *ptr);
/*< private >*/
capsule handle;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment