if (zv) {
zo = Z_OBJ_P(zv);
}
+ if (!zo) {
+ return NULL;
+ }
return (void *) (((char *) zo) - zo->handlers->offset);
}
ops->init(C);
}
- ZEND_ASSERT(ops->call != NULL);
- ZEND_ASSERT(ops->compile != NULL);
+ assert(ops->call != NULL);
+ assert(ops->compile != NULL);
/* build up predefs in a temporary PSI_Data for validation */
memset(&T, 0, sizeof(T));
static ffi_status psi_ffi_prep_closure(ffi_closure **closure, void **code, ffi_cif *sig, void (*handler)(ffi_cif*,void*,void**,void*), void *data) {
*closure = psi_ffi_closure_alloc(sizeof(ffi_closure), code);
- ZEND_ASSERT(*closure != NULL);
+ assert(*closure != NULL);
#if PSI_HAVE_FFI_PREP_CLOSURE_LOC
return ffi_prep_closure_loc(*closure, sig, handler, data, *code);
rc = ffi_prep_cif(signature, base->abi, argc + va_count, base->rtype, param_types);
#endif
- ZEND_ASSERT(FFI_OK == rc);
+ assert(FFI_OK == rc);
}
static inline ffi_type *psi_ffi_decl_arg_type(struct psi_decl_arg *darg);
rc = ffi_prep_cif(&call->signature, psi_ffi_abi(decl->abi->convention),
c, psi_ffi_decl_arg_type(decl->func), call->params);
- ZEND_ASSERT(FFI_OK == rc);
+ assert(FFI_OK == rc);
return call;
}
static inline ffi_type *psi_ffi_token_type(token_t t) {
switch (t) {
default:
- ZEND_ASSERT(0);
+ assert(0);
/* no break */
case PSI_T_VOID:
return &ffi_type_void;
static ffi_type **psi_ffi_struct_type_elements(struct psi_decl_struct *strct) {
size_t i = 0, argc = psi_plist_count(strct->args), nels = 0, offset = 0, maxalign = 0;
- ffi_type **els = calloc(argc + 1, sizeof(*els));
+ ffi_type **tmp, **els = calloc(argc + 1, sizeof(*els));
struct psi_decl_arg *darg;
while (psi_plist_get(strct->args, i++, &darg)) {
if ((padding = psi_offset_padding(darg->layout->pos - offset, type->alignment))) {
if (nels + padding + 1 > argc) {
argc += padding;
- els = realloc(els, (argc + 1) * sizeof(*els));
+ tmp = realloc(els, (argc + 1) * sizeof(*els));
+ if (tmp) {
+ els = tmp;
+ } else {
+ free(els);
+ return NULL;
+ }
els[argc] = NULL;
}
psi_ffi_struct_type_pad(&els[nels], padding);
L->params[0] = &ffi_type_pointer;
L->params[1] = &ffi_type_pointer;
rc = ffi_prep_cif(&L->signature, FFI_DEFAULT_ABI, 2, &ffi_type_void, L->params);
- ZEND_ASSERT(rc == FFI_OK);
+ assert(rc == FFI_OK);
return L;
}
{
switch (t) {
default:
- ZEND_ASSERT(0);
+ assert(0);
/* no break */
case PSI_T_VOID:
return jit_type_void;
/* apply struct alignment padding */
offset = (offset + maxalign - 1) & ~(maxalign - 1);
- ZEND_ASSERT(offset <= strct->size);
+ assert(offset <= strct->size);
if (offset < strct->size) {
nels += psi_jit_struct_type_pad(&(*fields)[nels], strct->size - offset);
}
signature = jit_type_create_signature(jit_abi_vararg,
jit_type_get_return(info->signature), param_types, argc + va_count,
1);
- ZEND_ASSERT(signature);
+ assert(signature);
info->impl.fn.frame = frame;
jit_apply(signature, decl->sym, args, argc, rval);
} else {
tmp->ptr = "";
}
- } else if (0 && Z_TYPE_P(zvalue) == IS_STRING) {
- tmp->ptr = Z_STRVAL_P(zvalue);
} else {
zend_string *zs = zval_get_string(zvalue);
tmp->ptr = estrdup(zs->val);
return ptr;
}
- val = val_ptr = calloc(var->pointer_level + 1, sizeof(void *));
+ val = calloc(var->pointer_level + 1, sizeof(void *));
+ val_ptr = val;
for (i = !var->arg->var->array_size; i < var->pointer_level; ++i) {
#if 0
fprintf(stderr, "++\n");
size_t i = 0;
struct psi_decl_enum_item *item;
- ++level;
while (psi_plist_get(e->items, i++, &item)) {
if (i > 1) {
dprintf(fd, ",\n");
}
- dprintf(fd, "%s", psi_t_indent(level));
+ dprintf(fd, "%s", psi_t_indent(level + 1));
psi_decl_enum_item_dump(fd, item);
}
- --level;
}
dprintf(fd, "\n}");
}
void psi_set_exp_exec(struct psi_set_exp *val, struct psi_call_frame *frame)
{
- struct psi_call_frame_symbol *frame_sym = NULL;
+ struct psi_call_frame_symbol *frame_sym;
struct psi_call_frame_argument *frame_arg;
struct psi_decl_var *set_dvar = psi_set_exp_get_decl_var(val);
struct psi_impl_var *set_ivar = psi_set_exp_get_impl_var(val);
return true;
default:
- complex: switch (psi_decl_type_get_real(set_var->arg->type)->type) {
+ complex:
+ switch (psi_decl_type_get_real(set_var->arg->type)->type) {
case PSI_T_UNION:
case PSI_T_STRUCT:
break;
struct psi_impl *impl)
{
if (!set->outer
- || set->outer->kind
- != PSI_SET_FUNC|| set->outer->data.func->type != PSI_T_TO_ARRAY) {
+ || set->outer->kind != PSI_SET_FUNC
+ || set->outer->data.func->type != PSI_T_TO_ARRAY) {
data->error(data, func->token, PSI_WARNING,
"Expected to_array() as parent to recursion in `set` statement"
" of implementation '%s'",
return false;
}
break;
- case PSI_T_ELLIPSIS:
- abort();
- if (!psi_set_func_validate_to_recursive(data, func, set, impl)) {
- return false;
- }
- break;
default:
data->error(data, func->token, PSI_WARNING,
"Unknown cast '%s' in `set` statement of implementation '%s'",