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

Home » Public Forums » archive » Re: how to pass array from dll into IDL?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: how to pass array from dll into IDL? [message #25723 is a reply to message #25635] Fri, 06 July 2001 17:04 Go to previous message
Randall Frank is currently offline  Randall Frank
Messages: 17
Registered: October 1999
Junior Member
Nigel,
Make sure you supply a free_cb function in your example.

The line:

array = IDL_ImportArray(1, dims, IDL_TYP_BYTE, data, NULL, NULL);

should read something like:

array = IDL_ImportArray(1, dims, IDL_TYP_BYTE, data,
(IDL_ARRAY_FREE_CB)free, NULL);

to avoid a memory leak in your example.

FWIW.


>
> data.c:
>
> #include <stdlib.h>
> #include <stdio.h>
> #include <unistd.h>
> #include <errno.h>
>
> #include "export.h"
>
> #define DATALEN 250
>
> IDL_VPTR get_data(int argc, IDL_VPTR argv[], char *argk)
> {
>
> IDL_VPTR array;
> IDL_LONG dims[IDL_MAX_ARRAY_DIM];
>
> IDL_VPTR result;
>
> unsigned char *data;
> int i;
>
> /*
> * get the data
> */
> data = malloc(DATALEN);
> if ( data == NULL )
> IDL_MESSAGE( IDL_M_NAMED_GENERIC, IDL_MSG_RET, strerror(errno));
>
> for ( i = 0; i < DATALEN; i++ )
> data[i] = i + 1;
>
> /*
> * create the return data array
> */
> dims[0] = DATALEN;
>
> array = IDL_ImportArray(1, dims, IDL_TYP_BYTE, data, NULL, NULL);
>
> return array;
> }
>
> int IDL_Load(void) {
>
> static IDL_SYSFUN_DEF function_addr[] = {
> { get_data, "GET_DATA", 0, 0, 0},
> };
>
> return IDL_AddSystemRoutine(function_addr, TRUE, 1);
> }
>
> data.dlm:
>
> MODULE data
> DESCRIPTION Create a simple data array.
> VERSION 1.0
> SOURCE Nigel Wade, Leicester University.
> BUILD_DATE July 6, 2001
> FUNCTION get_data 0 0

--
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
[Message index]
 
Read Message
Read Message
Previous Topic: Re: clever trick for reading .mat
Next Topic: Newsgroup archive

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

Current Time: Fri Oct 10 22:15:23 PDT 2025

Total time taken to generate the page: 1.91740 seconds