|
Re: desallocate an array of double passed by a library [message #48938 is a reply to message #48848] |
Wed, 31 May 2006 16:04  |
codepod
Messages: 19 Registered: March 2006
|
Junior Member |
|
|
The method to use will depend on the type of dynamic memory being used.
If you have a library that is allocating memory for you, you will want
to use the IDL_ImportArray() function. You can provide a C function
pointer to IDL_ImportArray() and IDL will call this when it's no longer
using the imported memory. This allows you to use the appropriate
deallocation method (free, delete, ...etc) for the imported memory.
If you want IDL to allocate the memory for an array and return the
variable to the to the interpreter, you can use IDL_MakeTempArray().
Note the variable this creates is a temporary variable and it must be a
return value from the function or copied into a passed in variable
using IDL_VarCopy() For more information consult the External
Development Guide. It's a PDF that ships with IDL.
The function IDL_GetScratch() is intended to create interpreter safe
memory (temporary memory) for use within a system (C) routine, but not
to return the created variable to the caller of the routine. While
returning scratch memory will probably not cause an error if the
variable flags are set correct, it's recommended to use the above array
creation routines which verify the correct size and structure of the
allocated memory as well as set the appropriate flags.
Cheers,
-CP
J. Fallou wrote:
> kuyper@wizard.net wrote:
>> Julien wrote:
>>> Hello,
>>>
>>> I'd like to know if it's possible to desallocate by IDL an variable
>>> created by an C dynamic librarie.
>>>
>>> thank of advance,
>>>
>>> J .Fallou
>>
>> I'm no expert; I've been waiting for the experts to chime in on this
>> one, but so far I've seen no responses.
>>
>> I believe that if you use the C routines provided by IDL to create IDL
>> variables, such as IDL_MakeStruct() and IDL_StrStore() and
>> IDL_GetScratch(), that those variables can be deallocated within the
>> calling IDL code just like any other variable.
>
> Ok thanks, I try IDL_GetScratch() tomorrow.
|
|
|