Re: Expert information needed [message #33880] |
Wed, 05 February 2003 02:09 |
Nigel Wade
Messages: 286 Registered: March 1998
|
Senior Member |
|
|
Ed Wright wrote:
>
> Can someone explain the operation differences between:
>
>
> IDL_VarCopy(IDL_StrToSTRING(shape_buf), Argv[2]);
This creates a new IDL_VAR and puts it into Argv[2].
>
> and
>
> IDL_StrStore( &Argv[2]->value.str, shape_buf );
This copies the string into Argv[2], which must be writable. It doesn't free
any memory currently in used by Argv[2], it assumes it contains garbage. As
a precursor to IDL_StrStore I would call
IDL_StoreScalarZero( Argv[2], IDL_TYP_STRING );
to free any resources which Argv[2] might be using and to set its type to
IDL_TYP_STRING (unless I'd created the variable myself in the routine and
new it didn't have any resources allocated).
>
> I discovered use of the second causes a malloc error under certain
> circumstances, while the first does not.
What were the contents of Argv[2] on entry?
>
> As always,
> ED Wright
--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
|
|
|