default:
return;
}
- free(def->type->name);
- def->type->name = strdup(def->var->name);
+ zend_string_release(def->type->name);
+ def->type->name = zend_string_copy(def->var->name);
}
static inline void psi_parser_proc_add_typedef(struct psi_parser *P, struct psi_decl_arg *def)
{
static inline void psi_parser_proc_add_decl(struct psi_parser *P, struct psi_decl *decl) {
assert(decl);
- if (psi_decl_is_blacklisted(decl->func->var->name)) {
+ if (psi_decl_is_blacklisted(decl->func->var->name->val)) {
psi_decl_free(&decl);
return;
}
}
}
| lib {
- char *libname = strdup($lib->text);
+ char *libname = strdup($lib->text->val);
P->file.libnames = psi_plist_add(P->file.libnames, &libname);
}
| constant {
}
| ignored_decl {
if (P->flags & PSI_DEBUG) {
- P->error(PSI_DATA(P), $ignored_decl->func->token, PSI_NOTICE, "Ignored decl: %s", $ignored_decl->func->var->name);
+ P->error(PSI_DATA(P), $ignored_decl->func->token, PSI_NOTICE, "Ignored decl: %s", $ignored_decl->func->var->name->val);
}
psi_decl_free(&$ignored_decl);
}
while (psi_plist_get($tokens, index++, &next)) {
struct psi_token *old = msg;
msg = psi_token_cat(" ", 2, msg, next);
- free(old);
+ psi_token_free(&old);
}
}
psi_plist_free($tokens);
}
| quoted_strings[token] {
$val = psi_impl_def_val_init($token->type, $token->text);
- $val->token = psi_token_copy($token);
+ $val->token = $token;
}
;
}
;
-decl_real_type[type]:
+decl_real_type[type]: /* allocated, so free, if set */
FLOAT[type_] {
$type = psi_token_copy($type_);
}
| UNSIGNED
;
-int_width[i]:
+int_width[i]: /* allocated, so free, if set */
SHORT {
$i = psi_token_copy($SHORT);
}
}
;
-decl_int_type[type]:
+decl_int_type[type]: /* allocated, so free, if set */
CHAR {
$type = psi_token_copy($CHAR);
}
| int_signed int_signed_types {
if ($2) {
$type = psi_token_cat(" ", 2, $1, $2);
- free($2);
+ psi_token_free(&$2);
} else {
$type = psi_token_copy($1);
}
| int_width int_width_types {
if ($2) {
$type = psi_token_cat(" ", 2, $1, $2);
- free($1);
- free($2);
+ psi_token_free(&$1);
+ psi_token_free(&$2);
} else {
$type = $1;
}
}
;
-int_signed_types[type]:
+int_signed_types[type]: /* allocated, so free, if set */
%empty {
$type = NULL;
}
| LONG INT
;
-int_width_types[type]:
+int_width_types[type]: /* allocated, so free, if set */
%empty {
$type = NULL;
}
| int_signed int_signed_types {
if ($2) {
$type = psi_token_cat(" ", 2, $1, $2);
- free($2);
+ psi_token_free(&$2);
} else {
$type = psi_token_copy($1);
}
decl decl_asm EOS {
$decl_stmt = $decl;
if ($decl_asm) {
- $decl->redir = strdup($decl_asm->text);
- free($decl_asm);
+ $decl->redir = zend_string_copy($decl_asm->text);
+ psi_token_free(&$decl_asm);
}
}
| CPP_EXTENSION decl decl_asm EOS {
$decl_stmt = $decl;
if ($decl_asm) {
- $decl->redir = strdup($decl_asm->text);
- free($decl_asm);
+ $decl->redir = zend_string_copy($decl_asm->text);
+ psi_token_free(&$decl_asm);
}
}
;
}
| quoted_strings[strings_] QUOTED_STRING {
$strings = psi_token_cat("", 2, $strings_, $QUOTED_STRING);
- free($strings_);
+ psi_token_free(&$strings_);
}
;
struct psi_decl_var *var;
while (psi_plist_get($vars, i++, &var)) {
- if (psi_decl_extvar_is_blacklisted(var->name)) {
+ if (psi_decl_extvar_is_blacklisted(var->name->val)) {
psi_decl_var_free(&var);
} else {
- list = psi_plist_add(list, psi_decl_extvar_init(
- psi_decl_arg_init(psi_decl_type_copy($decl_arg->type), var)));
- }
+ struct psi_decl_extvar *evar = psi_decl_extvar_init(
+ psi_decl_arg_init(psi_decl_type_copy($decl_arg->type), var));
+ list = psi_plist_add(list, &evar);
+ }
}
free($vars);
}
- if (psi_decl_extvar_is_blacklisted($decl_arg->var->name)) {
+ if (psi_decl_extvar_is_blacklisted($decl_arg->var->name->val)) {
psi_decl_arg_free(&$decl_arg);
} else {
struct psi_decl_extvar *evar = psi_decl_extvar_init($decl_arg);
;
ignored_decl:
- STATIC decl_body ignored_decl_body {
- $ignored_decl = $decl_body;
-}
-| STATIC CPP_INLINE decl_body ignored_decl_body {
- $ignored_decl = $decl_body;
-}
-| CPP_INLINE decl_body ignored_decl_body {
- $ignored_decl = $decl_body;
-}
-| NAME CPP_INLINE decl_body ignored_decl_body {
+ ignored_decl_qualifiers decl_body ignored_decl_body {
$ignored_decl = $decl_body;
}
;
+ignored_decl_qualifiers:
+ STATIC
+| STATIC CPP_INLINE
+| CPP_EXTENSION CPP_INLINE
+| CPP_EXTENSION STATIC CPP_INLINE
+| CPP_INLINE
+| NAME CPP_INLINE
+;
+
ignored_decl_body:
LBRACE ignored_decl_body_stmts RBRACE
;
type->real.func = rval_decl;
func->var->token = psi_token_copy($NAME);
func->token = psi_token_copy($NAME);
+ type->token = type_token;
$decl = psi_decl_init(func, $args);
}
char digest[17];
struct psi_token *name;
- psi_token_hash($decl->func ->token, digest);
+ psi_token_hash($decl->func->token, digest);
name = psi_token_append("@", psi_token_copy($decl->func->token), 2, "funct", digest);
$arg = psi_decl_arg_init(
$sizeof = psi_number_init(PSI_T_INT8, &sizeof_a, 0);
}
| QUOTED_STRING {
- uint64_t len = $QUOTED_STRING->size + 1;
+ uint64_t len = $QUOTED_STRING->text->len + 1;
$sizeof = psi_number_init(PSI_T_UINT64, &len, 0);
}
;
$l = NULL;
}
| COLON NUMBER[width] {
- $l = psi_layout_init(0, 0, psi_layout_init(0, atol($width->text), NULL));
+ $l = psi_layout_init(0, 0, psi_layout_init(0, atol($width->text->val), NULL));
}
| COLON COLON LPAREN NUMBER[align] COMMA NUMBER[size] RPAREN {
- $l = psi_layout_init(atol($align->text), atol($size->text), NULL);
+ $l = psi_layout_init(atol($align->text->val), atol($size->text->val), NULL);
}
| COLON NUMBER[width] COLON COLON LPAREN NUMBER[align] COMMA NUMBER[size] RPAREN {
- $l = psi_layout_init(atol($align->text), atol($size->text), psi_layout_init(0, atol($width->text), NULL));
+ $l = psi_layout_init(atol($align->text->val), atol($size->text->val), psi_layout_init(0, atol($width->text->val), NULL));
}
;
$as.len = 0;
}
| COLON COLON LPAREN NUMBER[align] COMMA NUMBER[size] RPAREN {
- $as.pos = atol($align->text);
- $as.len = atol($size->text);
+ $as.pos = atol($align->text->val);
+ $as.len = atol($size->text->val);
}
;