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

Home » Public Forums » archive » Re: Pointer Help - Referencing/Dereferencing in Functions & Procedures
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
Re: Pointer Help - Referencing/Dereferencing in Functions & Procedures [message #34370] Wed, 12 March 2003 12:50 Go to next message
Chris[1] is currently offline  Chris[1]
Messages: 23
Registered: January 2003
Junior Member
You need to pass an argument into your procedure; as far as it knows
"number_ptr" hasn't been declared.

Change the first line of number_proc to:

pro number_proc, number_ptr

and the call in $MAIN$ to

number_proc,number_ptr



and it should work.


Chris
Re: Pointer Help - Referencing/Dereferencing in Functions & Procedures [message #34465 is a reply to message #34370] Wed, 12 March 2003 15:57 Go to previous message
JD Smith is currently offline  JD Smith
Messages: 850
Registered: December 1999
Senior Member
On Wed, 12 Mar 2003 13:50:55 -0700, Chris wrote:

> You need to pass an argument into your procedure; as far as it knows
> "number_ptr" hasn't been declared.
>
> Change the first line of number_proc to:
>
> pro number_proc, number_ptr
>
> and the call in $MAIN$ to
>
> number_proc,number_ptr
>
>
>
> and it should work.
>
>
> Chris


Which is to say that, even though the heap of data to which a pointer
points is available globally, the pointer itself is not. In fact, when
you lose the pointer, but the heap data remains, this is a memory leak:

IDL> a=ptr_new(fltarr(1000))
IDL> a=1 ; uh oh, where's the pointer?
IDL> help,/heap
Heap Variables:
# Pointer: 1
# Object : 0

<PtrHeapVar1> FLOAT = Array[1000]

Here you see data on the global "pointer heap", but since you
overwrote the pointer referring to it with "1", it's lost. It's still
on the heap, but you just can't get to it (unless you know some arcane
tricks). You can clean it up with:

IDL> heap_gc,/verbose
<PtrHeapVar1> FLOAT = Array[1000]

That got rid of it. So, in order to use the data a pointer points to,
you need to pass the pointer in as an argument, or perhaps save it in
a common block so you can get to it from anywhere.

JD
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: SPECIII?
Next Topic: Pointer Help - Referencing/Dereferencing in Functions & Procedures

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

Current Time: Sat Oct 11 10:07:42 PDT 2025

Total time taken to generate the page: 1.12367 seconds