[pypy-commit] cffi default: Issue #217: use memcpy() instead of manually copying the data. On

arigo noreply at buildbot.pypy.org
Wed Aug 26 09:05:43 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r2256:b8169a197564
Date: 2015-08-26 09:04 +0200
http://bitbucket.org/cffi/cffi/changeset/b8169a197564/

Log:	Issue #217: use memcpy() instead of manually copying the data. On
	some architecture, the target is not correctly aligned for "void *".

diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -3582,7 +3582,6 @@
            array      [ctype, length]
            funcptr    [ctresult, ellipsis+abi, num_args, ctargs...]
     */
-    long i;
     PyObject *key, *y;
     const void **pkey;
     int err;
@@ -3592,8 +3591,7 @@
         goto error;
 
     pkey = (const void **)PyBytes_AS_STRING(key);
-    for (i = 0; i < keylength; i++)
-        pkey[i] = unique_key[i];
+    memcpy(pkey, unique_key, keylength * sizeof(void *));
 
     y = PyDict_GetItem(unique_cache, key);
     if (y != NULL) {


More information about the pypy-commit mailing list