R-alpha: new version

Thomas Lumley thomas@biostat.washington.edu
Fri, 25 Jul 1997 11:45:57 -0700 (PDT)


I have traced down the segfault that Venkat and I reported with C
routines. It is in S_alloc, which explains why only some routines cause
problems.

The problem is that size is declared but never set, resulting in
(xxgdb) print size
$10 = 1081754432

I don't know precisely what is happening here but my guess is that we
should have size=nelem*eltsize/sizeof(char). 

(Q: Is it necessary or even true that eltsize/sizeof(char) is always an
integer?) 

char *S_alloc(long nelem, int eltsize)
{
	unsigned int i, size;
	char *p = R_alloc(nelem, eltsize);
	for(i=0 ; i<size; i++)
		p[i] = 0;
	return p;
}


Thomas Lumley
------------------------------------------------------+------
Biostatistics		: "Never attribute to malice what  :
Uni of Washington	:  can be adequately explained by  :
Box 357232		:  incompetence" - Hanlon's Razor  :
Seattle WA 98195-7232	:				   :
------------------------------------------------------------

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-