www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/15/13:07:09

From: Rudolf Polzer <rpolzer AT gmx DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Replacing malloc(size) with new and delete - is that possible
Date: Mon, 15 Mar 1999 17:31:11 GMT
Organization: Deja News - The Leader in Internet Discussion
Lines: 26
Message-ID: <7cjg4v$556$1@nnrp1.dejanews.com>
References: <Pine DOT GSO DOT 3 DOT 95 DOT 990311095808 DOT 9547A-100000 AT hlrz18>
NNTP-Posting-Host: 193.227.244.61
X-Article-Creation-Date: Mon Mar 15 17:31:11 1999 GMT
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)
X-Http-Proxy: 1.1 x16.dejanews.com:80 (Squid/1.1.22) for client 193.227.244.61
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

In article <Pine DOT GSO DOT 3 DOT 95 DOT 990311095808 DOT 9547A-100000 AT hlrz18>,
  djgpp AT delorie DOT com wrote:
> rpolzer AT gmx DOT de asked:
>
> > Can I do the following: (in C++)
> >
> > struct PACKET {
> > // ... some data
> > char P_DATA[0];
>              ^^^
> > };
>
> Typo, I guess. (By the way, if you want to use C++ anyway,
> the string class may be helpful.)
>

No, it was just that I DIDN'T KNOW how big P_DATA will be. The packets should
be sent through TCP/IP and contained some other fields. OK, I also can use
classes, but I would have to copy P_DATA and PACKET into a new array which is
much overhead. I did this very often in Turbo Pascal with switched-off range
checking. I wanted to know if a p = (...) new char[n] could replace malloc
and a delete [] (char *) p could replace free. But, the exe file grew if
using this, so that the answer is now irrelevant to me.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

- Raw text -


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