[pypy-svn] r77337 - pypy/trunk/pypy/rpython/lltypesystem

arigo at codespeak.net arigo at codespeak.net
Fri Sep 24 13:34:01 CEST 2010


Author: arigo
Date: Fri Sep 24 13:33:59 2010
New Revision: 77337

Modified:
   pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
Log:
Fix:  ctypes.sizeof() can return 0, e.g. for structs with no field.


Modified: pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py	(original)
+++ pypy/trunk/pypy/rpython/lltypesystem/ll2ctypes.py	Fri Sep 24 13:33:59 2010
@@ -36,7 +36,7 @@
         pieces = far_regions._ll2ctypes_pieces
         num = random.randrange(len(pieces))
         i1, stop = pieces[num]
-        i2 = i1 + (ctypes.sizeof(ctype) + 7) & ~7
+        i2 = i1 + ((ctypes.sizeof(ctype) or 1) + 7) & ~7
         if i2 > stop:
             raise MemoryError("out of memory in far_regions")
         pieces[num] = i2, stop



More information about the Pypy-commit mailing list