[PATCH] python: Store pointers as c_void_p to keep references
James Westby
jw+debian at jameswestby.net
Thu Dec 1 15:25:43 PST 2011
On Thu, 1 Dec 2011 18:13:05 -0500, James Westby <jw+debian at jameswestby.net> wrote:
> From: James Westby <james.westby at linaro.org>
>
> ctypes doesn't return c_void_p return values as that, it returns them as
> 32-bit integers instead. This has two problems:
>
> 1 - On 64-bit machines anything higher than the max 32-bit integer
> will overflow when passed back in to another function expecting,
> a pointer giving the wrong value.
>
> 2 - If the value isn't stored as a pointer then the memory can be
> re-used and so the object will be corrupted.
>
> The fix for both of these is to store the values as pointers.
http://osdir.com/ml/python.ctypes/2006-12/msg00048.html states that this
is expected behaviour of ctypes.
Thanks,
James
More information about the notmuch
mailing list