From: Ron Grunwald Organization: Edith Cowan University To: kagel AT ts1 DOT bloomberg DOT com Date: Wed, 14 Jun 1995 09:40:28 GMT+800 Subject: Re: Malloc without malice 2 Reply-To: r DOT grunwald AT cowan DOT edu DOT au Cc: djgpp AT sun DOT soe DOT clarkson DOT edu Art S. Kagel wrote: > I have a sort program I ported to DJGPP which malloc() and free()s all over the > place and it has never failed. I have sorted files of several hundred thousand > records which translates to over 1/2 million malloc()s and matching free()s. > Doing around 1/2 million function calls to malloc(), isn't that a bit inefficient, considering the enourmous execution thread the system has to follow to allocate a single block of memory? Using the stack might be a much faster method as you only need 3 assembly language instructions for the same task. Eg. push ebp mov ebp,esp sub ebp,BLOCKSZ Regards, Ron. ******************************************************************** | Author.............. Ron Grunwald | | Internet............ r DOT grunwald AT cowan DOT edu DOT au | | Phone............... (09)273 8027 or (09)273 8468 | |------------------------------------------------------------------| | Department.......... Computer Operations and Systems Management | | Division/Faculty.... Information Technology | | Institute........... Edith Cowan University, Churchlands | | Location............ Perth, Western Australia | ******************************************************************** "I don't have any solution but I certainly admire the problem!"