From: Erik Max Francis Newsgroups: comp.os.msdos.djgpp Subject: Re: How big can I make my array? Date: Mon, 08 Jun 1998 18:11:19 -0700 Organization: Alcyone Systems Lines: 30 Message-ID: <357C8BB7.72AB4B6D@alcyone.com> References: <3578C43D DOT F4DDB90 AT cs DOT com> <357AB3E4 DOT 316B4ED2 AT cs DOT com> <357c0c3a DOT 24494159 AT news DOT Austria DOT EU DOT net> NNTP-Posting-Host: charmaine.alcyone.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Gerhard Gruber wrote: > I heard this a number of times but I don't see any advantage or > disadvantage. > When I allocate i.e. a string (like char *x = malloc(n)) I don't see > the > reason why I should use new instead of malloc(). Is there a drawback > to > malloc()? If you are using classes with constructors, you will want to use operator new, since it will automatically call the object's constructor. You won't want to use malloc in that case. If you are just allocate blocks of data, you can use either, but you shouldn't mix-and-match the two allocation methods (i.e., never delete a block allocated with malloc, and never free a block allocated with new). The malloc routines still have their use, since you can resize malloc-allocated blocks in one call with realloc, but can't do an analogous thing with operator new/delete (unless you do the work yourself). -- Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com Alcyone Systems / http://www.alcyone.com/max/ San Jose, California, United States / icbm:+37.20.07/-121.53.38 \ She glanced at her watch / . . . It was 9:23. / James Clavell