Re: GPC compiler crash

"Prof A Olowofoyeku (The African Chief)" <[email protected]>
Newsgroups gmane.comp.compilers.gpc
Organization ChiefSoft
Message-ID <[email protected]>
On 17 Feb 2013 at 12:59, Thomas Schneider wrote:

> Prof:
> 
> > It is a very large data structure (about 490mb). It doesn't make a lot
> > of sense to have a static variable of that size. It is probably better
> > to use a pointer. That way, it can be a local variable:
> > 
> > procedure themain(var da: text);
> > var
> > dataprism: ^trisquare;   (* the data structure for diana *)
> 
> I don't understand.  What that would gain me?

procedure themain(var da: text);
var
  dataprism: ^trisquare;  
begin
   new (dataprism);
   writeln(output,' trimdiana -gpc bug',version:4:2);
   writeprism(da, dataprism^);
   dispose (dataprism);
end;

The dataprism pointer is 4 bytes on a 32-bit system. I don't know its 
size on a 64-bit system (i.e., whether it is 4 or 8 bytes - probably 
the latter); "sizeof (pointer)" should give you that information.

Pointers (or, at least, what they point to) are allocated on the heap, 
so you will not overflow the stack like you did when you declared 
dataprism as a local trisquare variable. Using a pointer, you are only 
playing with 4 or 8 bytes on the stack, whereas, before, you were 
playing with 490mb (which would overflow any stack).

Best regards, The Chief
--------
Prof. Abimbola A. Olowofoyeku (The African Chief) 
web:  http://www.greatchief.plus.com/


_______________________________________________
Gpc mailing list
[email protected]
https://www.g-n-u.de/mailman/listinfo/gpc
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.