From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,345a8b767542016e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-15 09:25:16 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: kcline@optelnow.net (Kevin Cline) Newsgroups: comp.lang.ada Subject: Re: memory leakages with Ada? Date: 15 Mar 2002 09:25:16 -0800 Organization: http://groups.google.com/ Message-ID: References: <3c90af1e@news.starhub.net.sg> NNTP-Posting-Host: 198.23.5.11 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1016213116 20151 127.0.0.1 (15 Mar 2002 17:25:16 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 15 Mar 2002 17:25:16 GMT Xref: archiver1.google.com comp.lang.ada:21297 Date: 2002-03-15T17:25:16+00:00 List-Id: "Steve Doiel" wrote in message news:... > "Calvin Ow" wrote in message > news:3c90af1e@news.starhub.net.sg... > > Hi, > > Has Ada got any memory leakage problems like that of C? > > Especially with the use of Pragma calls to C? > > > > I'll assume you read the other replies to your post. > > I would like to add that there are many cases in Ada where you don't need to > use dynamic allocation when you would have to use dynamic allocation in C. > > For example, if you want to read a block of data that is preceded by a count > that gives the amount of data, in Ada the code would be something like: > > nbBytes := GetNbBytes( dataSource ); > declare > dataBuffer : ByteBuffer( 1 .. nbBytes ); > begin > GetData( dataBuffer ); > end; > > Where in C the code would look something like: > > nbBytes = GetNbBytes( dataSource ); > dataPtr = (char *)calloc( nbBytes ); > GetData( dataPtr ); > free( dataPtr ); No problem in C++ though: nbBytes = GetNbBytes( dataSource ); std::vector data(nbBytes); GetData( data );