Date: Thu, 21 Aug 1997 17:42:57 +1100 From: Bill Currie Subject: Re: [Q] wrapping functions with linker In-reply-to: <5tg75j$sj3$1@newton.pacific.net.sg> To: fesenko AT pacific DOT net DOT sg (Victor), djgpp AT delorie DOT com Message-id: <199708210547.RAA21366@teleng1.tait.co.nz gatekeeper.tait.co.nz> Organization: Tait Electronics Limited MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Comments: Authenticated sender is Precedence: bulk On 21 Aug 97 at 16:55, Victor wrote: > #define mprintf(format,args...) {fi=fopen("malloc.log","a"); > fprintf(fi,format,## args); fclose(fi);} That's your problem: fopen calls malloc which (for you) calls fopen which calls malloc... I got tipped off by esp in your stack dump being so low. Try, instead (no guarantees, I'm not sure about opening for append, I've never done it): #include void mprintf(const char *fmt, ...) { int fd=open ("malloc.log", O_TEXT|O_CREAT|O_APPEND, S_IWUSR) static char buff[1024]; /* dangerous if the output string is too long */ va_list args; va_start (args, fmt); vsprintf (buff, fmt, args); va_end (args); write (fd, buff, strlen (buff)); close (fd); } HTH Bill -- Leave others their otherness.