Mail Archives: djgpp/1997/08/25/23:00:54
Victor wrote:
> void* malloc(size_t size)
> { void *p=(void*)(__imd+___im__ptr);
> if(WRITE_TO_LOGFILE)
> mprintf(" Program requested %8li bytes. Ptr =
> %li\n",size,___im__ptr);
UUhhh!!! Never NEVER use such things without exactly
knowlage about the internals!!
You cannot use at least fopen() in malloc()!! This function
itself calls again malloc() and so you will go in an endless
recursion!!
Either you use write() or something else. And also NEVER
use stream io functions in malloc() without deeply thinking
about it, because malloc() is called already in the startup code!!
When remember I did something like this is the past similar
to the following (not tested, only an idea):
static int write_to_log = 0;
static FILE *logfile;
void *maolloc(size_t size)
{
if (write_to_log)
fprintf(logfile,...)
....
}
...
int main()
{
logfile = fopen("logfile",...);
write_to_log = 1;
....
write_to_log = 0;
fclose(logfile);
return 0;
}
Robert
---
*****************************************************************
* Robert Hoehne, Fakultaet fuer Mathematik, TU-Chemnitz-Zwickau *
* Post: Am Berg 3, D-09573 Dittmannsdorf *
* e-Mail: Robert DOT Hoehne AT Mathematik DOT TU-Chemnitz DOT DE *
* WWW: http://www.tu-chemnitz.de/~rho *
*****************************************************************
- Raw text -