Returning a string array from a DLM [message #33187] |
Thu, 12 December 2002 15:44  |
Ed Wright
Messages: 39 Registered: February 1999
|
Member |
|
|
Question for DLM experts:
I wrote a DLM for a C routine that returns an array of strings. The first
version of the DLM code has the return array declared as char item[X][Y].
After the C call, I created a temp array of strings via a IDL_MakeTempArray
call, then looped over each string in the array copying the string to the
array created in IDL_MakeTempArray via an IDL_StrStore call.
It worked..
So being quite industrious, I decided it a good idea to dynamically allocate
the memory required for the string array. After a few hours of aggravation
and a phone call to a friend who reminded me a pointer pointing to nothing
might cause some problems, I have a DLM than can dynamically allocate the
needed space for a string array then pass that array to my C routine as an
argument for return.
Now the problem. On return to the IDL interpreter, I experience a plethora
of malloc errors:
Given a script making two calls to the DLM, call format:
cspice_lparse, string_with_separator, separator_string, item
Item should return as an array of strings.
My test output -
IDL> xtspice_idl
Start tests
% Loaded DLM: COMBINE.
Start of module: st01_idl
In C routine:
String: a
String: b
String: c
In IDL, array = a b c
In C routine:
String: a
String:
String: c
*** malloc[3990]: error for object 0x29cee0: Incorrect check sum for freed
object - object was probably modified after beeing freed; break at
szone_error
Segmentation fault
Any ideas as to my error? I do free the allocated array as the last step.
As always,
Ed Wright
|
|
|