Mail Archives: djgpp/1997/08/21/01:42:36
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 <stdarg.h>
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.
- Raw text -