| delorie.com/archives/browse.cgi | search |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
| Date: | Fri, 7 Dec 2001 01:05:27 +0100 |
| From: | Henning Moll <DrScott AT gmx DOT de> |
| X-Mailer: | The Bat! (v1.53d) Personal |
| Reply-To: | Henning Moll <DrScott AT gmx DOT de> |
| X-Priority: | 3 (Normal) |
| Message-ID: | <14214257250.20011207010527@gmx.de> |
| To: | cygwin AT cygwin DOT com |
| Subject: | problems with dlopen |
| MIME-Version: | 1.0 |
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/
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |