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

Home » Public Forums » archive » Proper pointer cleanup question
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Proper pointer cleanup question [message #34679] Mon, 07 April 2003 16:01
MKatz843 is currently offline  MKatz843
Messages: 98
Registered: March 2002
Member
I want to make sure I'm taking all the steps necessary to clean up
pointers and free memory when I'm done with them. Here's an example.

Suppose I have a pointer to a structure that contains pointers.

a = ptr_new({n:10, p:ptrarr(10)})

So, a is a pointer, and ((*a).p)(i) are pointers as well.
When I'm done with a and all of it's components, I can do a few things
to clean it up, but I don't want to do more than what's necessary.
Here's a few options.

1) Just a:
ptr_free, a

2) a and all of its dependent pointers:
for i=0,n_elements( (*a).p )-1 do $
ptr_free, ((*a).p)(i)
ptr_free, a

3) Re-assign a to a scalar:
a = 0

4) Re-assign *a to a scalar:
*a = 0


What's the best thing to do? My pointed-to arrays are going to get
pretty large, so I don't want to strand any memory unnecessarily.

Thanks,
M. Katz
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Reading gzip compressed files with SOCKET?
Next Topic: font size

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

Current Time: Wed Oct 08 13:04:55 PDT 2025

Total time taken to generate the page: 0.00711 seconds