@@ -295,56 +295,13 @@ static int zend_ffi_is_compatible_type(zend_ffi_type *dst_type, zend_ffi_type *s
295
295
296
296
static ffi_type * zend_ffi_make_fake_struct_type (zend_ffi_type * type ) /* {{{ */
297
297
{
298
- ffi_type * t = emalloc (sizeof (ffi_type ) + sizeof (ffi_type * ) * (zend_hash_num_elements (& type -> record .fields ) + 1 ));
299
- int i ;
300
- zend_ffi_field * field ;
298
+ ffi_type * t = emalloc (sizeof (ffi_type ) + sizeof (ffi_type * ));
301
299
302
300
t -> size = type -> size ;
303
301
t -> alignment = type -> align ;
304
302
t -> type = FFI_TYPE_STRUCT ;
305
303
t -> elements = (ffi_type * * )(t + 1 );
306
- i = 0 ;
307
- ZEND_HASH_FOREACH_PTR (& type -> record .fields , field ) {
308
- switch (ZEND_FFI_TYPE (field -> type )-> kind ) {
309
- case ZEND_FFI_TYPE_FLOAT :
310
- t -> elements [i ] = & ffi_type_float ;
311
- break ;
312
- case ZEND_FFI_TYPE_DOUBLE :
313
- t -> elements [i ] = & ffi_type_double ;
314
- break ;
315
- #ifdef HAVE_LONG_DOUBLE
316
- case ZEND_FFI_TYPE_LONGDOUBLE :
317
- t -> elements [i ] = & ffi_type_longdouble ;
318
- break ;
319
- #endif
320
- case ZEND_FFI_TYPE_SINT8 :
321
- case ZEND_FFI_TYPE_UINT8 :
322
- case ZEND_FFI_TYPE_BOOL :
323
- case ZEND_FFI_TYPE_CHAR :
324
- t -> elements [i ] = & ffi_type_uint8 ;
325
- break ;
326
- case ZEND_FFI_TYPE_SINT16 :
327
- case ZEND_FFI_TYPE_UINT16 :
328
- t -> elements [i ] = & ffi_type_uint16 ;
329
- break ;
330
- case ZEND_FFI_TYPE_SINT32 :
331
- case ZEND_FFI_TYPE_UINT32 :
332
- t -> elements [i ] = & ffi_type_uint32 ;
333
- break ;
334
- case ZEND_FFI_TYPE_SINT64 :
335
- case ZEND_FFI_TYPE_UINT64 :
336
- t -> elements [i ] = & ffi_type_uint64 ;
337
- break ;
338
- case ZEND_FFI_TYPE_POINTER :
339
- t -> elements [i ] = & ffi_type_pointer ;
340
- break ;
341
- default :
342
- efree (t );
343
- return NULL ;
344
- }
345
- i ++ ;
346
- } ZEND_HASH_FOREACH_END ();
347
- t -> elements [i ] = NULL ;
304
+ t -> elements [0 ] = NULL ;
348
305
return t ;
349
306
}
350
307
/* }}} */
@@ -391,11 +348,7 @@ static ffi_type *zend_ffi_get_type(zend_ffi_type *type) /* {{{ */
391
348
kind = type -> enumeration .kind ;
392
349
goto again ;
393
350
case ZEND_FFI_TYPE_STRUCT :
394
- if (!(type -> attr & ZEND_FFI_ATTR_UNION )) {
395
- ffi_type * t = zend_ffi_make_fake_struct_type (type );
396
- return t ;
397
- }
398
- break ;
351
+ return zend_ffi_make_fake_struct_type (type );
399
352
default :
400
353
break ;
401
354
}
@@ -2534,18 +2487,13 @@ static int zend_ffi_pass_arg(zval *arg, zend_ffi_type *type, ffi_type **pass_typ
2534
2487
kind = type -> enumeration .kind ;
2535
2488
goto again ;
2536
2489
case ZEND_FFI_TYPE_STRUCT :
2537
- if (!(type -> attr & ZEND_FFI_ATTR_UNION )
2538
- && Z_TYPE_P (arg ) == IS_OBJECT && Z_OBJCE_P (arg ) == zend_ffi_cdata_ce ) {
2490
+ if (Z_TYPE_P (arg ) == IS_OBJECT && Z_OBJCE_P (arg ) == zend_ffi_cdata_ce ) {
2539
2491
zend_ffi_cdata * cdata = (zend_ffi_cdata * )Z_OBJ_P (arg );
2540
2492
2541
2493
if (zend_ffi_is_compatible_type (type , ZEND_FFI_TYPE (cdata -> type ))) {
2542
- /* Create a fake structure type */
2543
- ffi_type * t = zend_ffi_make_fake_struct_type (type );
2544
- if (t ) {
2545
- * pass_type = t ;
2546
- arg_values [n ] = cdata -> ptr ;
2547
- break ;
2548
- }
2494
+ * pass_type = zend_ffi_make_fake_struct_type (type );;
2495
+ arg_values [n ] = cdata -> ptr ;
2496
+ break ;
2549
2497
}
2550
2498
}
2551
2499
zend_ffi_pass_incompatible (arg , type , n , execute_data );
0 commit comments