[Tutor] pass a memory pointer to a c function

Nathan Smith nathan-tech at hotmail.com
Sat Jan 29 20:34:56 EST 2022


Hi list,


Put simply, I have a c function which takes a memory pointer as one of 
the arguments, "An unmanaged pointer to the memory location as an 
IntPtr." which I am calling from a python program.


I've done some digging and it looks like tempfile can write to the 
memory, but can I use that to then get the pointer and pass it over?

More digging seems to indicate id(obj) gets the memory location for that 
object, but as it is a python object I'm guessing that is not much use?

What I want the function to receive is the memory pointer for the data 
in the tempfile, rather than the python tempfile object.


I've also figured out that ctypes.pointer(i) is probably what I want, 
where i is a ctypes.c_int(python_int) of some kind, but getting py_int 
to be the correct memory locations is my stumbling block


Sorry in advance if my terms are off here, I'm only a passing c user and.

I hope someone can point me in the right direction!

Nathan

-- 

Best Wishes,

Nathan Smith, BSC


My Website: https://nathantech.net




More information about the Tutor mailing list