comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: allocate heap? yes or no?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: allocate heap? yes or no? [message #39318] Mon, 17 May 2004 06:26 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Marc Schellens writes:

Marc pretty much covers all the ground related to pointers.
I was trying to think if I use a rule of thumb about when
and where to allocate heap. Then I realized I *used* to
do a lot of heap allocating, but these days I hardly do
it at all.

I think when I started working with pointers (and especially
when they were associated with objects) I had several
"entry" points in the program where pointers could be
set (INIT, SetProperty methods, etc.) It seemed smart
to allocate heap in the INIT method, then I didn't have
to worry about checking if the pointer was valid in the
SetProperty method.

But I think what happened is that I found it too easy to
leak pointer memory with this approach. These days I
do my "checking" with PTR_VALID instead of N_ELEMENTS
and if the pointer isn't valid, I just make a new one.
This makes the pointer easy to destroy at appropriate
times without worrying about whether I have to also
allocate a new pointer with heap memory. It just makes
the pointer accounting a LOT easier for me if I *don't*
allocate heap.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Read Message
Previous Topic: virtual mosaic template format in ENVI
Next Topic: Re: Unpacking algorithm

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:11:34 PDT 2025

Total time taken to generate the page: 0.00418 seconds