www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/24/10:55:14

Date: Thu, 24 Apr 1997 10:38:30 -0400 (EDT)
From: "art s. kagel IFMX x2697" <kagel AT dg1 DOT bloomberg DOT com>
To: SteelGolem <myork AT auracom DOT com>
Cc: djgpp AT delorie DOT com
Subject: Re: memory allocation: malloc vs. calloc
In-Reply-To: <5jk1rm$la8$1@thor.atcon.com>
Message-Id: <Pine.D-G.3.91.970424102456.20048B-100000@dg1>
Mime-Version: 1.0

Calloc() allocates memory then zeros it out.  Malloc() returns 
uninitialized, read garbage filled, memory which you must initialize.  

BTW, for portability I prefer to use malloc() then memset()/bzero() 
because I have worked on two compilers with broken calloc() functions 
which did not properly initialize memory.  The calloc() in DJGPP is fine 
but if you are planning on porting to other "C" compilers ... caveat 
emptor. 

Art S. Kagel, kagel AT ts1 DOT bloomberg DOT com

On Wed, 23 Apr 1997, SteelGolem wrote:

> what's the difference between using malloc and calloc? being a beginner
> DJGPP user, should i worry about it and just use malloc? or is there
> something i should know about? email and news post, pleeze!
> 
> steelgolem
> 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019