Mail Archives: djgpp/1994/12/09/19:15:08
I wrote the following function for fast filling strings with a character
(like the BASIC STRING$ function). I compiled the program succesfully
but when I ran it, it crashed. It wrote an extremely big value to the
variable [_nextf+8]. (I think it's used internally by malloc() for
registrating memory allocation. The value it wrote was 0xfffff839, a
very-very illegal address, which is used when malloc() is called.
Of course it caused either an unhandled page fault or a General Pro-
tection Fault.
My questions are:
1. What is _nextf and by the way where can I find a documentation of
the program's internal system variables (I'm only a beginner with C
so I can't get much information from the compiler's and go32's
sources.)
2. What's wrong with the following function?
char* string(int n,char c)
{
char* ts;
ts=(char*)malloc(n+1);
memset(ts,c,n);
ts[n]=0;
return(ts);
}
- Raw text -