| 1 |
diff -ur Python-2.6~/Modules/_ctypes/callbacks.c Python-2.6/Modules/_ctypes/callbacks.c
|
| 2 |
--- Python-2.6~/Modules/_ctypes/callbacks.c 2008-06-09 00:58:54.000000000 -0400
|
| 3 |
+++ Python-2.6/Modules/_ctypes/callbacks.c 2009-03-17 00:08:38.424528546 -0400
|
| 4 |
@@ -21,8 +21,8 @@
|
| 5 |
Py_XDECREF(self->converters);
|
| 6 |
Py_XDECREF(self->callable);
|
| 7 |
Py_XDECREF(self->restype);
|
| 8 |
- if (self->pcl)
|
| 9 |
- FreeClosure(self->pcl);
|
| 10 |
+ if (self->pcl_write)
|
| 11 |
+ ffi_closure_free(self->pcl_write);
|
| 12 |
PyObject_Del(self);
|
| 13 |
}
|
| 14 |
|
| 15 |
@@ -373,7 +373,8 @@
|
| 16 |
return NULL;
|
| 17 |
}
|
| 18 |
|
| 19 |
- p->pcl = NULL;
|
| 20 |
+ p->pcl_exec = NULL;
|
| 21 |
+ p->pcl_write = NULL;
|
| 22 |
memset(&p->cif, 0, sizeof(p->cif));
|
| 23 |
p->converters = NULL;
|
| 24 |
p->callable = NULL;
|
| 25 |
@@ -402,8 +403,9 @@
|
| 26 |
|
| 27 |
assert(CThunk_CheckExact(p));
|
| 28 |
|
| 29 |
- p->pcl = MallocClosure();
|
| 30 |
- if (p->pcl == NULL) {
|
| 31 |
+ p->pcl_write = ffi_closure_alloc(sizeof(ffi_closure),
|
| 32 |
+ &p->pcl_exec);
|
| 33 |
+ if (p->pcl_write == NULL) {
|
| 34 |
PyErr_NoMemory();
|
| 35 |
goto error;
|
| 36 |
}
|
| 37 |
@@ -448,7 +450,9 @@
|
| 38 |
"ffi_prep_cif failed with %d", result);
|
| 39 |
goto error;
|
| 40 |
}
|
| 41 |
- result = ffi_prep_closure(p->pcl, &p->cif, closure_fcn, p);
|
| 42 |
+ result = ffi_prep_closure_loc(p->pcl_write, &p->cif, closure_fcn,
|
| 43 |
+ p,
|
| 44 |
+ p->pcl_exec);
|
| 45 |
if (result != FFI_OK) {
|
| 46 |
PyErr_Format(PyExc_RuntimeError,
|
| 47 |
"ffi_prep_closure failed with %d", result);
|
| 48 |
diff -ur Python-2.6~/Modules/_ctypes/_ctypes.c Python-2.6/Modules/_ctypes/_ctypes.c
|
| 49 |
--- Python-2.6~/Modules/_ctypes/_ctypes.c 2008-08-19 15:40:23.000000000 -0400
|
| 50 |
+++ Python-2.6/Modules/_ctypes/_ctypes.c 2009-03-17 00:08:38.479530502 -0400
|
| 51 |
@@ -3438,7 +3438,7 @@
|
| 52 |
self->callable = callable;
|
| 53 |
|
| 54 |
self->thunk = thunk;
|
| 55 |
- *(void **)self->b_ptr = (void *)thunk->pcl;
|
| 56 |
+ *(void **)self->b_ptr = (void *)thunk->pcl_exec;
|
| 57 |
|
| 58 |
Py_INCREF((PyObject *)thunk); /* for KeepRef */
|
| 59 |
if (-1 == KeepRef((CDataObject *)self, 0, (PyObject *)thunk)) {
|
| 60 |
diff -ur Python-2.6~/Modules/_ctypes/ctypes.h Python-2.6/Modules/_ctypes/ctypes.h
|
| 61 |
--- Python-2.6~/Modules/_ctypes/ctypes.h 2008-07-24 07:16:45.000000000 -0400
|
| 62 |
+++ Python-2.6/Modules/_ctypes/ctypes.h 2009-03-17 00:08:38.480528344 -0400
|
| 63 |
@@ -95,7 +95,8 @@
|
| 64 |
|
| 65 |
typedef struct {
|
| 66 |
PyObject_VAR_HEAD
|
| 67 |
- ffi_closure *pcl; /* the C callable */
|
| 68 |
+ ffi_closure *pcl_write; /* the C callable, writeable */
|
| 69 |
+ void *pcl_exec; /* the C callable, executable */
|
| 70 |
ffi_cif cif;
|
| 71 |
int flags;
|
| 72 |
PyObject *converters;
|
| 73 |
diff -ur Python-2.6~/setup.py Python-2.6/setup.py
|
| 74 |
--- Python-2.6~/setup.py 2009-03-17 00:07:54.771651851 -0400
|
| 75 |
+++ Python-2.6/setup.py 2009-03-17 00:08:19.792558478 -0400
|
| 76 |
@@ -1701,8 +1701,7 @@
|
| 77 |
'_ctypes/callbacks.c',
|
| 78 |
'_ctypes/callproc.c',
|
| 79 |
'_ctypes/stgdict.c',
|
| 80 |
- '_ctypes/cfield.c',
|
| 81 |
- '_ctypes/malloc_closure.c']
|
| 82 |
+ '_ctypes/cfield.c']
|
| 83 |
depends = ['_ctypes/ctypes.h']
|
| 84 |
|
| 85 |
if sys.platform == 'darwin':
|