Subject: Re: SIGSEGV error when using big float matrix under pvm
To: None <current-users@NetBSD.ORG>
From: Patrick Welche <prlw1@cam.ac.uk>
List: current-users
Date: 05/17/1997 17:25:29
David Brownlee wrote:
> 
> 	You are almost certainly running out of stack space.
> 
> 	You should be able to get more stack space by typing
> 	'unlimit stacksize'. On i386 this would increase the stack from
> 	512K to 8MB, and on the sparc from 512K to 64MB.
> 
> 	The other (more correct) option would be to use malloc() or
> 	calloc(), but I dont know how to malloc multidimentional arrays
> 	offhand (other than to fudge it by allocating a single dimentional
> 	array and passing it into a function that expects a
> 	multidimentional array (uck))
> 
> 	eg: Something like:

?

float **ptr;
int m=5, n=8;
register int i;

if(ptr=(float **)calloc(m,sizeof(float *)),ptr==(float **)NULL)
  {fprintf(stderr,"Memory allocation error.\n");exit(1);}
for(i=0;i<m;++i)
  {
    if(ptr[i]=(float *)calloc(n,sizeof(float)),ptr[i]==(float *)NULL)
      {fprintf(stderr,"Memory allocation error.\n");exit(1);}
  }

ptr[3][6]=3.14;
printf("%f\n",ptr[3][6]);


?

Patrick