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

Home » Public Forums » archive » Returning a string array from a DLM
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Returning a string array from a DLM [message #33187] Thu, 12 December 2002 15:44 Go to previous message
Ed Wright is currently offline  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
[Message index]
 
Read Message
Read Message
Previous Topic: Re: Windows, LCC & call_external
Next Topic: Inverse Hyberbolic Tangent

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

Current Time: Wed Oct 08 15:33:25 PDT 2025

Total time taken to generate the page: 0.00424 seconds