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

CALL_EXTERNAL and strarr()



I need to call an external C function (unix/shared lib method) which
will collect a string array of different size strings.  I have been
using call_external with success on returning other types (floats,
strings etc) but this seems more challenging.  The problem being I don't
know how large each string will be in the string array so it needs to be
dynamically allocated.


I know the following can pass IN a string array and return a single
string:

replyStr = CALL_EXTERNAL('IDLquery_call.so','GetPatientList',strarr,$
                   N_ELEMENTS(strarr),  /S_VALUE)

the key point in the C function being to make the returned string static
to avoid memory leaks.

Anyone care to point out how I might be able to retrieve a string array.

I was thinking about IDL_ImportArray or IDL_ImportNamedArray to create
an IDL Array.

so lets say in my C function I have

 char *list[100] ;    or should it be IDL_STRING *list100 ; ??????

and the function has gone off an filled this list with various sized
array strings.
(eg. list[0] = strdup("5char")   list[1] = strdup("06char") where strdup
is using malloc implicitly)

Assuming I create an IDL array from this data, what mechanism do I have
of returning this data in the call_external function.

Thanks in Advance
Rich