Skip to content

Commit 6ed388b

Browse files
committed
revise set_blob types
We were seeing exceptions with older libvipses because ffi throws an exception on type error in ABI mode. Instead, move the type fudging to C, so we just get a compile-time warning in API mode.
1 parent 03453ff commit 6ed388b

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

CHANGELOG.rst

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* update enums.py [tony612]
66
* add gen-enums.py [jcupitt]
77
* improve custom source/target types [jcupitt]
8+
* revise types for set_blob [jcupitt]
89

910
## Version 2.1.11 (7 Nov 2019)
1011

pyvips/gvalue.py

+3
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ def set(self, value):
221221
vips_lib.vips_value_set_blob_free(self.gvalue,
222222
memory, len(value))
223223
else:
224+
# we declare the type of the free func in set_blob incorrectly
225+
# so that we can pass g_free at runtime without triggering an
226+
# exception
224227
if pyvips.API_mode:
225228
vips_lib.vips_value_set_blob(self.gvalue,
226229
ffi.NULL, memory, len(value))

pyvips/vdecls.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ def cdefs(features):
107107
void vips_value_set_array_int (GValue* value,
108108
const int* array, int n );
109109
void vips_value_set_array_image (GValue *value, int n);
110-
typedef int (*VipsCallbackFn)(void* a, void* b);
110+
typedef void (*FreeFn)(void* a);
111111
void vips_value_set_blob (GValue* value,
112-
VipsCallbackFn free_fn, void* data, size_t length);
112+
FreeFn free_fn, void* data, size_t length);
113113
114114
bool g_value_get_boolean (const GValue* value);
115115
int g_value_get_int (GValue* value);

0 commit comments

Comments
 (0)