[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Casting from an Octave int value to a pointer.
From: |
mpender |
Subject: |
Re: Casting from an Octave int value to a pointer. |
Date: |
Wed, 22 Jan 2014 18:04:15 -0800 (PST) |
I think I've got it working. An example follows below since this issue
appears to have come up before but a solution was not presented. If anyone
has an example of how to modify the contents of a global array from an oct
file that would really be the best way to address the issue. I found the
example of how to modify a global scalar in the Octave documentation, but
not a global array value.
#include <octave/oct.h>
#include <stdio.h>
#include <stdlib.h>
DEFUN_DLD (freetest1, args, nargout, "Free memory for a previously reserved
array.")
{
octave_value retval;
int nargin = args.length();
if (nargin != 1)
print_usage ();
else
{
unsigned long tmp1 = args(0).int_value();
float *tmp2;
tmp2 = reinterpret_cast<float *>(tmp1);
free(tmp2);
tmp2 = NULL;
}
return octave_value_list();
}
--
View this message in context:
http://octave.1599824.n4.nabble.com/Casting-from-an-Octave-int-value-to-a-pointer-tp4661233p4661293.html
Sent from the Octave - General mailing list archive at Nabble.com.