🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #17064

Re: Fixing a memory leak

#17064
From: Terry
Date: Fri, 11 Apr 2003 23:24
22 lines
1635 bytes
Great, thanks a lot, no more codeguard errors.

"Remy Lebeau (TeamB)" <gambit47@yahoo.com> wrote in message
news:3e971900$1@newsgroups.borland.com...
>
> > Try this:
> <snip>
>
> That is not valid.  The memory was allocated as a char[] but then
you're
> freeing it as a People* instead.  They must match.  So the memory
has to be
> freed as a char* using delete[] instead:
>
>     char *pBuf = ReadFileToBuffer("Database.dat", &FileSize);
>     if( pBuf )
>     {
>         PeopleType *People = (PeopleType*)pBuf;
>         // use People as needed
>
>         delete[] pBuf;
>     }
Technical Details
Message-ID: <3e974e81$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3e96fe40$1@newsgroups.borland.com> <3e970049$1@newsgroups.borland.com> <3e971900$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,23a77f481a630239
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-04-11 16:33:00 PST
Reply-To: "Terry" <terry@helloworld.com>
From: "Terry" <terry@helloworld.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References:  <3e96fe40$1@newsgroups.borland.com> <3e970049$1@newsgroups.borland.com> <3e971900$1@newsgroups.borland.com>
Subject: Re: Fixing a memory leak
Date: Fri, 11 Apr 2003 18:24:01 -0500
Lines: 24
Organization: here
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 66.142.144.216
Message-ID: <3e974e81$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1050103425 66.142.144.216 (11 Apr 2003 16:23:45 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail