decl_type *real = real_decl_type(type);
switch (real->type) {
- case PSI_T_FUNCTION:
- return &ffi_type_pointer;
-
case PSI_T_STRUCT:
- if (!real->strct->engine.type) {
+ if (!real->real.strct->engine.type) {
ffi_type *strct = calloc(1, sizeof(ffi_type));
strct->type = FFI_TYPE_STRUCT;
strct->size = 0;
- strct->elements = psi_ffi_struct_type_elements(real->strct);
+ strct->elements = psi_ffi_struct_type_elements(real->real.strct);
- real->strct->engine.type = strct;
- real->strct->engine.dtor = psi_ffi_struct_type_dtor;
+ real->real.strct->engine.type = strct;
+ real->real.strct->engine.dtor = psi_ffi_struct_type_dtor;
}
- return real->strct->engine.type;
+ return real->real.strct->engine.type;
case PSI_T_UNION:
- return psi_ffi_decl_arg_type(real->unn->args->args[0]);
+ return psi_ffi_decl_arg_type(real->real.unn->args->args[0]);
default:
return psi_ffi_token_type(real->type);
return L;
}
+static inline void PSI_LibffiContextFree(PSI_LibffiContext **L) {
+ if (*L) {
+ free(*L);
+ *L = NULL;
+ }
+}
+
static void psi_ffi_init(PSI_Context *C)
{
C->context = PSI_LibffiContextInit(NULL);
}
}
}
- free(C->context);
+ PSI_LibffiContextFree((void *) &C->context);
}
static zend_function_entry *psi_ffi_compile(PSI_Context *C)
continue;
}
- call = PSI_LibffiCallAlloc(C, impl->decl);
- if (FFI_OK != PSI_LibffiCallInitClosure(C, call, impl)) {
- PSI_LibffiCallFree(call);
- continue;
+ if ((call = PSI_LibffiCallAlloc(C, impl->decl))) {
+ if (FFI_OK != PSI_LibffiCallInitClosure(C, call, impl)) {
+ PSI_LibffiCallFree(call);
+ continue;
+ }
}
zf->fname = impl->func->name + (impl->func->name[0] == '\\');
for (c = 0; c < impl->stmts->let.count; ++c) {
let_stmt *let = impl->stmts->let.list[c];
- if (let->val->kind == PSI_LET_CALLBACK) {
+ if (let->val && let->val->kind == PSI_LET_CALLBACK) {
let_callback *cb = let->val->data.callback;
- call = PSI_LibffiCallAlloc(C, cb->decl);
- if (FFI_OK != PSI_LibffiCallInitCallbackClosure(C, call, cb)) {
- PSI_LibffiCallFree(call);
- continue;
- }
+ if ((call = PSI_LibffiCallAlloc(C, cb->decl))) {
+ if (FFI_OK != PSI_LibffiCallInitCallbackClosure(C, call, cb)) {
+ PSI_LibffiCallFree(call);
+ continue;
+ }
- cb->decl->call.sym = call->code;
+ cb->decl->call.sym = call->code;
+ }
}
}
}
for (i = 0; i < C->decls->count; ++i) {
decl *decl = C->decls->list[i];
-// if (decl->impl) {
-// continue;
-// }
if (decl->call.info) {
continue;
}