[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Allocating memory in LINKIMAGE program



Virginia,
	You can use something like this to return an array of (n)
strings:

s = (IDL_STRING *)IDL_MakeTempVector(IDL_TYP_STRING,
	n, IDL_BARR_INI_ZERO, &vpTmp);
for(i=0;i<n;i++) IDL_StrStore(s++,YourCStringArray[i]);
IDL_VarCopy(vpTmp,argv[0]);

	In general, do not pass memory you allocated with malloc back 
to IDL, especially if you want IDL to clean it up later for you.

Hope it helps.

Virginia Rogers wrote:
> 
> I have a C program which queries a database and returns a list of all matching
> entries.  I am making this routine callable in IDL with LINKIMAGE.  I'd like to
> return a string array to the calling IDL program.  My question is, how do I
> allocate the memory to store the strings?  The C program has allocated space for
> all of the strings with malloc().  Can I call IDL_MakeTempArray() to create the
> string array and then set each of the string pointers to point to the location
> allocated by malloc()?  Is there another source of information about using
> LINKIMAGE other than the IDL Advanced Development Guide?
> 
> Thanks!  Ginny

-- 
rjf.
Randy Frank                            | ASCI Visualization
Lawrence Livermore National Laboratory | rjfrank@llnl.gov
B451 Room 2039  L-561                  | Voice: (925) 423-9399
Livermore, CA 94550                    | Fax:   (925) 423-8704