ctypes - posix_memalign within python -
I do not understand why the following does not work
import ctypes From ctypes.util import find_library libc = ctypes.CDLL (find_library ('c')) userpointer = ctypes.c_void_p sizeimage = 320 * 240 * 2 if libc.posix_memalign (userpointer, libc.getpagesize (), size) = 0: raise Exception ('isom')
I'm trying to capture using v4l2. I can not allocate the memory ctypes.addressof (userpointer) tried to pass
I tried cvvoid_p to put userpointer but still nothing.
In your code, you have two problems: You can use the userpointer instead of an example ctypes.c_void_p < Em> type , and you are going through zero * which is directly posix_memalign to userpointer, instead of zero ** that requires posix_memalign The following is what you want to do:
< Code> ctypes.util import from import ctypes import_library libc = ctypes.CDLL (find_library ('c')) userpointer = ctypes.c_void_p () sizeimage = 320 * 240 * 2 if libc.posix_memalign (ctypes.byref (userpointer) Libc.getpagesize (), sizeimage) = 0: Exception increases A. ( 'ENOMEM')
Comments
Post a Comment