🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pilot.programmer.codewarrior
Article #26

Re: char* memory leak with emulator 3.5

#26
From: David Ladanyi
Date: Thu, 10 Oct 2002 05:03
20 lines
2193 bytes
psaStr is a local variable.  Where and how do I deallocate the memory
so that I dont get a memory leak? Apparently the Palm OS will not
deallocate the memory itself when the field contain dynamic memory and
the clean up function I put in (called on frmCloseEvent) seemed to do
nothing. If I'm using the wrong strategy then what am I supposed to
do?
 

Ben Combee <combee@techwood.org> wrote in message news:<MPG.180dcfbc414a20d79898c2@news.earthlink.net>...
> In article <30890494.0210080905.64899638@posting.google.com>, 
> david_ladanyi@yahoo.com says...
> > When I put in a "delete psaStr" line it produced a memory error
> > because the pointer was being used by the field. I managed to fix the
> > problem by declaring "char psaStr[6];" instead of "char* psaStr = new
> > char[6];"
> 
> Is psaStr a local variable or a global?  If its local, you might have 
> just passed a pointer to stack space into a global structure -- this is 
> bad, as that space can and will be used for other variables after the 
> current function exits.
Technical Details
Message-ID: <30890494.0210092103.6be4a94b@posting.google.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!postnews1.google.com!not-for-mail
References: <30890494.0210062256.7a8a8fa@posting.google.com> <uq35nhqhshk23@corp.supernews.com> <30890494.0210080905.64899638@posting.google.com> <MPG.180dcfbc414a20d79898c2@news.earthlink.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109d41,fc0bc5958a8d445f
X-Google-Attributes: gid109d41,public
X-Google-Thread: 10baa0,fc0bc5958a8d445f
X-Google-Attributes: gid10baa0,public
X-Google-ArrivalTime: 2002-10-09 22:03:48 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!postnews1.google.com!not-for-mail
From: david_ladanyi@yahoo.com (David Ladanyi)
Newsgroups: pilot.programmer.codewarrior,codewarrior.palm
Subject: Re: char* memory leak with emulator 3.5
Date: 9 Oct 2002 22:03:48 -0700
Organization: http://groups.google.com/
Lines: 20
Message-ID: <30890494.0210092103.6be4a94b@posting.google.com>
References: <30890494.0210062256.7a8a8fa@posting.google.com> <uq35nhqhshk23@corp.supernews.com> <30890494.0210080905.64899638@posting.google.com> <MPG.180dcfbc414a20d79898c2@news.earthlink.net>
NNTP-Posting-Host: 209.244.243.136
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1034226228 14368 127.0.0.1 (10 Oct 2002 05:03:48 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 10 Oct 2002 05:03:48 GMT