Skip to content

Commit b5fe050

Browse files
committed
oswrapper_image C++ fixes
1 parent a477373 commit b5fe050

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

oswrapper_image.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,11 @@ extern void *objc_autoreleasePoolPush(void);
192192
#ifdef __cplusplus
193193
}
194194
#endif
195+
#define OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_TYPE void*
195196
#define OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_POP(pool) objc_autoreleasePoolPop(pool)
196197
#define OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_PUSH() objc_autoreleasePoolPush()
197198
#else
199+
#define OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_TYPE id
198200
#define OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_POP(pool) oswrapper__objc_msgSend_t(void)(pool, sel_registerName("drain"))
199201
#define OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_PUSH() oswrapper__objc_alloc_init(objc_getClass("NSAutoreleasePool"))
200202
#endif
@@ -275,7 +277,7 @@ OSWRAPPER_IMAGE_DEF void oswrapper_image_free_nocopy(OSWrapper_image_decoded_dat
275277
}
276278

277279
OSWRAPPER_IMAGE_DEF OSWrapper_image_decoded_data* oswrapper_image_load_from_memory_nocopy(unsigned char* image, int length, int* width, int* height, int* channels) {
278-
void* autorelease_pool = OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_PUSH();
280+
OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_TYPE autorelease_pool = OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_PUSH();
279281
CFDataRef image_data_cf = CFDataCreateWithBytesNoCopy(NULL, image, length, kCFAllocatorNull);
280282
id bitmap = oswrapper__setup_image_from_memory((id) image_data_cf, width, height, channels);
281283
CFRelease(image_data_cf);
@@ -292,7 +294,7 @@ OSWRAPPER_IMAGE_DEF OSWrapper_image_decoded_data* oswrapper_image_load_from_memo
292294

293295
#ifndef OSWRAPPER_IMAGE_NO_LOAD_FROM_PATH
294296
OSWRAPPER_IMAGE_DEF OSWrapper_image_decoded_data* oswrapper_image_load_from_path_nocopy(const char* path, int* width, int* height, int* channels) {
295-
void* autorelease_pool = OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_PUSH();
297+
OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_TYPE autorelease_pool = OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_PUSH();
296298
id bitmap = oswrapper__setup_image_from_path(path, width, height, channels);
297299

298300
if (bitmap == nil) {
@@ -314,7 +316,7 @@ OSWRAPPER_IMAGE_DEF void oswrapper_image_free(unsigned char* image_data) {
314316
}
315317

316318
OSWRAPPER_IMAGE_DEF unsigned char* oswrapper_image_load_from_memory(unsigned char* image, int length, int* width, int* height, int* channels) {
317-
void* autorelease_pool = OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_PUSH();
319+
OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_TYPE autorelease_pool = OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_PUSH();
318320
CFDataRef image_data_cf = CFDataCreateWithBytesNoCopy(NULL, image, length, kCFAllocatorNull);
319321
id bitmap = oswrapper__setup_image_from_memory((id) image_data_cf, width, height, channels);
320322
CFRelease(image_data_cf);
@@ -332,7 +334,7 @@ OSWRAPPER_IMAGE_DEF unsigned char* oswrapper_image_load_from_memory(unsigned cha
332334

333335
#ifndef OSWRAPPER_IMAGE_NO_LOAD_FROM_PATH
334336
OSWRAPPER_IMAGE_DEF unsigned char* oswrapper_image_load_from_path(const char* path, int* width, int* height, int* channels) {
335-
void* autorelease_pool = OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_PUSH();
337+
OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_TYPE autorelease_pool = OSWRAPPER_IMAGE__OBJC_AUTORELEASE_POOL_PUSH();
336338
id bitmap = oswrapper__setup_image_from_path(path, width, height, channels);
337339

338340
if (bitmap == nil) {

0 commit comments

Comments
 (0)