Author: Armin Rigo <[email protected]>
Branch: cffi-1.0
Changeset: r77369:935c34fb54a2
Date: 2015-05-17 21:37 +0200
http://bitbucket.org/pypy/pypy/changeset/935c34fb54a2/
Log: move the hack
diff --git a/pypy/module/_cffi_backend/cdlopen.py
b/pypy/module/_cffi_backend/cdlopen.py
--- a/pypy/module/_cffi_backend/cdlopen.py
+++ b/pypy/module/_cffi_backend/cdlopen.py
@@ -93,6 +93,9 @@
def allocate(ffi, nbytes):
nbytes = llmemory.raw_malloc_usage(nbytes)
+ if not we_are_translated():
+ nbytes *= 2 # hack to account for the fact that raw_malloc_usage()
+ # returns an approximation, ignoring padding and
alignment
p = lltype.malloc(rffi.CCHARP.TO, nbytes, flavor='raw', zero=True)
ffi._finalizer.free_mems.append(p)
return p
@@ -100,9 +103,6 @@
@specialize.arg(1)
def allocate_array(ffi, OF, nitems):
nbytes = llmemory.raw_malloc_usage(rffi.sizeof(OF))
- if not we_are_translated():
- nbytes *= 2 # hack to account for the fact that raw_malloc_usage()
- # returns an approximation, ignoring padding and
alignment
p = allocate(ffi, nitems * nbytes)
return rffi.cast(rffi.CArrayPtr(OF), p)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit