[SciPy-user] numpy array in ctype struct
Rob Hetland
hetland at tamu.edu
Thu Jan 24 02:39:24 EST 2008
On Jan 23, 2008, at 3:44 PM, Ryan May wrote:
> I may be grokking this incorrectly, but I think your problem lies
> here.
> I'm not sure what you're trying to accomplish with this loop (since
> setting to NULL isn't necessary before free-ing). What it actually
> does
> is set the value at the memory address located at pts[i] to NULL (0).
> This will end up modifying the values in pts1 itself. (Since pts[i] =
> pts1 + i*dim, then *pts[i] is the same as pts1[i*dim].)
This part wasn't intended to be the 'real' code, rather I just was
trying different things out. I guess I didn't explain this well
enough in my last message. Resetting the pointers like this does not
seem to change the numpy array passed to the *double pointer, whereas
freeing the new **double does erase those values.
>>
>> free(pts); /// this seems to also delete the input data (pts1)
>> in python..
>
> I'm not sure this is really the case. It looks like a perfect
> match for
> the malloc above.
Yes, that's what I thought, but it doesn't seem to work like I
thought it would.
> If that loop isn't causing the problem, then the problem likely lies
> elsewhere.
Yes, after your comments, it seems that is the only thing left.. I
was just checking to see if someone had run across this before. I
had tested for other possible problems, but I guess I will have to
keep looking.
-Rob
----
Rob Hetland, Associate Professor
Dept. of Oceanography, Texas A&M University
http://pong.tamu.edu/~rob
phone: 979-458-0096, fax: 979-845-6331
More information about the SciPy-User
mailing list