🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pilot.programmer
Article #26

Re: freeing memory from uneditable field

#26
From: Ben Combee
Date: Tue, 17 Sep 2002 05:10
23 lines
1964 bytes
In article <30890494.0209161101.52834dd7@posting.google.com>, 
david_ladanyi@yahoo.com says...
> Hi
> 
> I'm cant seem to free the memory I've allocated for a string that I'm
> using in an uneditable field. Here's how I'm initializing it:

First, it its an uneditable field, then just use FldGetTextPtr and 
FldSetTextPtr.  You don't need to mess with field handles unless the 
field is marked as editable.

One key thing is to make sure that when you're deallocating the field's 
text, you do it in this order:

1) ptr = FldGetTextPtr
2) FldSetTextPtr(NULL)
3) MemPtrFree(ptr)

Setting the internal pointer to NULL prevents a double free situation.
-- 
Ben Combee <bcombee@metrowerks.com>
CodeWarrior for Palm OS technical lead
Get help at http://palmoswerks.com/
Technical Details
Message-ID: <MPG.17f0746f121439f1989892@news.earthlink.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news.stealth.net!news.stealth.net!central.cox.net!cox.net!newsfeed1.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail
References: <30890494.0209161101.52834dd7@posting.google.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10c638,3aff17f5064426b6
X-Google-Attributes: gid10c638,public
X-Google-Thread: 10baa0,3aff17f5064426b6
X-Google-Attributes: gid10baa0,public
X-Google-ArrivalTime: 2002-09-16 22:10:11 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news.stealth.net!news.stealth.net!central.cox.net!cox.net!newsfeed1.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail
From: Ben Combee <combee@techwood.org>
Newsgroups: pilot.programmer,codewarrior.palm
Subject: Re: freeing memory from uneditable field
Message-ID: <MPG.17f0746f121439f1989892@news.earthlink.net>
References: <30890494.0209161101.52834dd7@posting.google.com>
Organization: Techwood Broadcasting Foundation
X-Newsreader: MicroPlanet Gravity v2.60
Lines: 23
Date: Tue, 17 Sep 2002 05:10:11 GMT
NNTP-Posting-Host: 24.206.100.29
X-Complaints-To: abuse@earthlink.net
X-Trace: newsread2.prod.itd.earthlink.net 1032239411 24.206.100.29 (Mon, 16 Sep 2002 22:10:11 PDT)
NNTP-Posting-Date: Mon, 16 Sep 2002 22:10:11 PDT