problems with dlopen
Henning Moll
DrScott@gmx.de
Fri Dec 7 08:26:00 GMT 2001
Hello!
Why does this code fail with segfault?
I think the problem is that dlopen calls malloc itself? Is that right?
Any suggestions how to fix it?
--snip--
#include <stdlib.h>
#include <dlfcn.h>
static void *(*orig_malloc) (size_t) = 0;
void *
malloc(size_t p)
{
static int state = 0;
void * handle;
switch (state)
{
case 0:
handle = dlopen("cygwin1.dll", RTLD_NOW);
orig_malloc = (void *(*)(size_t)) dlsym (handle, "malloc");
state = 1;
/*fall through*/
case 1:
return (*orig_malloc) (p);
}
}
int
main()
{
return 0;
}
--snip--
Best regards,
Henning
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list