Mail Archives: djgpp/1996/10/09/11:29:30
Errors-To: postmaster AT ns1
Date: Wed, 9 Oct 1996 13:10:26 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
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
- Raw text -