From: kagel AT quasar DOT bloomberg DOT com Date: Wed, 9 Oct 1996 11:04:03 -0400 Message-Id: <9610091504.AA09586@quasar.bloomberg.com > To: eliz AT is DOT elta DOT co DOT il Cc: maad AT hem DOT passagen DOT se, djgpp AT delorie DOT com In-Reply-To: (message from Eli Zaretskii on Wed, 9 Oct 1996 13:10:26 +0200 (IST)) Subject: Re: The best way to allocate memory Reply-To: kagel AT dg1 DOT bloomberg DOT com Errors-To: postmaster AT ns1 Date: Wed, 9 Oct 1996 13:10:26 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is Cc: djgpp AT delorie DOT com Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Content-Length: 498 On 8 Oct 1996, Markus Malmgren wrote: > I wonder which of the follwing ways is the best to allocate memory, is it: > malloc, calloc, __dpmi_allocate_memory or __dpmi_allocate_linear_memory? Just use the usual C library functions `malloc' and `calloc'. The DPMI functions are DJGPP-specific and you don't need them for usual application programming. They should be only used for interfacing with special memory-mapped hardware or when you want to replace the library allocation functions. Also use calloc() when you require that the memory allocated be zero'd out and malloc otherwise. Calloc() tends to be slower due to the need to initialize. FYI: note that there are implementations of calloc() which do NOT properly initialize (VAX UNIX System V for one) so for portability I tend to just use malloc() and then memset() or bzero() the memory myself. -- Art S. Kagel, kagel AT quasar DOT bloomberg DOT com A proverb is no proverb to you 'till life has illustrated it. -- John Keats