Mail Archives: djgpp/1996/04/11/05:44:54
Eli Zaretskii wrote:
> Btw, allocating 5000 chunks of 10KB is a symptom of a very
> memory-inefficent program (IMHO). If a program indeed needs so many
> allocations, it should allocate memory in a few large chunks and then
> overload `new' with something that serves allocations off those chunks.
>
I implemented a ZBuffer class as:
(...)
int theHeight;
int theWidth;
double **theArray
(...)
The constructor allocated one (double *) array, theWidth items long,
and then theWidth double arrays, theHeight items long.
Then accessing the element (X, Y) was theArray [X][Y].
I will try to avoid the malloc crash using only a double * array:
(...)
int theHeight;
int theWidth;
double *theArray
(...)
and accessing the element (X,Y) as theArray [theWidth * Y + X]
Thank you.
Jesus.
--------------------------------------------------------------------------------
DIGITAL ILLUSION * Grup Matrust
Jesus Canal Trav. de les Corts, 222 * 08028 Barcelona (Spain)
Software Enginner Tel. (34-3) 409 01 15 * Fax (34-3) 409 01 16
mailto:jesus AT matrust DOT es * http://www.matrust.es
--------------------------------------------------------------------------------
- Raw text -