help-octave
[Top][All Lists]
Advanced

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

Re: Casting from an Octave int value to a pointer.


From: Pantxo
Subject: Re: Casting from an Octave int value to a pointer.
Date: Wed, 22 Jan 2014 04:55:55 -0800 (PST)

I have used the same strategy to return pointer address to the interpreter in
the past (see this thread [1]), but I was advised not to do so as the user
may change the value of the address and the free operation would lead to
unintended results.

Basically, I was advised to either store the pointer into a global static
variable inside my oct file (all DEFUN that need the pointer must be defined
in the same oct file in order to have access to the static variable), or
derive octave_base_value class so that the oct file can return a proper
octave object containing whatever pointer you like. 

If you really want to use the cast strategy I can search in my old files the
way I managed the operation. AFAIR the main issue was to test whether I was
on a 32 or 64 bit : sizeof(pointer) depends on the architecture but not
sizeof(int).

Pantxo

[1]
http://octave.1599824.n4.nabble.com/stroring-pointers-from-oct-files-td4646071.html



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Casting-from-an-Octave-int-value-to-a-pointer-tp4661233p4661250.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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