Message-ID: <316CE14F.5DDE@matrust.es> Date: Thu, 11 Apr 1996 11:39:11 +0100 From: Jesus Canal Organization: Digital Illusion (Grup Matrust) MIME-Version: 1.0 To: Eli Zaretskii CC: djgpp AT delorie DOT com Subject: Re: malloc crash References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 --------------------------------------------------------------------------------