www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/12/09/19:15:08

Date: Fri, 9 Dec 1994 16:30:52 +0100 (MET)
From: Hirling Endre <endre AT alpha1 DOT obuda DOT kando DOT hu>
To: DJGPP list <djgpp AT sun DOT soe DOT clarkson DOT edu>
Subject: Strange crashes

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019