help-octave
[Top][All Lists]
Advanced

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

Re: Dynamically linked C/C++ functions and file descriptor


From: A S Hodel
Subject: Re: Dynamically linked C/C++ functions and file descriptor
Date: Thu, 01 Feb 2001 19:38:23 -0600
User-agent: Microsoft-Outlook-Express-Macintosh-Edition/5.02.2022

I'll go ahead and display my own ignorance.

> on 2/1/01 6:37 PM, Joshua Rigler at address@hidden wrote:

> If some of my terminology and jargon is not quite correct, please
> forgive me, and if you're feeling really generous, enlighten me...
> 
> 1) Suppose I create a dynamically linked C++ function using mkoctfile.
> This function dynamically allocates some memory, and sets a static
> pointer for this memory location (using calloc).  The function exits,
> and I'm returned to Octave.  I call that function again.  Can I assume
> that the static pointer is still valid and points to the proper place in
> memory, as it would if I was simply calling the function from another
> C++ function?

I think the answer is "yes", but this sounds to me like a recipe for a
memory leak.

> 2) Maybe related...suppose I have a C++ function that generates a void
> pointer file descriptor (i.e. typedef void *CDFid). If I return that
> file descriptor to the parent Octave session, then use it in subsequent
> calls to other dynamically linked functions that use it, is that pointer
> still valid?
> 
[munch]
> 
> 3) Finally, how the heck can I return a pointer to Octave?  It doesn't
> seem to like anything but double floats and strings (and vectors,
> arrays, and complex versions of such).  Could I perhaps pass back a
> string of the hexidecimal format of the pointer, and then pass this
> between function calls, which would convert the string to the real
> pointer/address...is this even possible?

I don't think there's a "clean" (that is, portable) way to do this, since
you correctly identify the problem that Octave's variables are double or
string values.

-- 
A S Hodel Assoc. Prof. Dept Elec. Comp. Eng.  Auburn Univ, AL 36849-5201
(334) 844-1854 Fax -1809 http://www.eng.auburn.edu/~scotte



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]