projects
/
m6w6
/
ext-psi
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
fix leaks
[m6w6/ext-psi]
/
src
/
cpp_tokiter.c
diff --git
a/src/cpp_tokiter.c
b/src/cpp_tokiter.c
index 57645ec0db2ffccdd906116b29382777547c321e..8073281ea7c80f12043e2d0644edbd6844dee53b 100644
(file)
--- a/
src/cpp_tokiter.c
+++ b/
src/cpp_tokiter.c
@@
-128,8
+128,8
@@
bool psi_cpp_tokiter_del_cur(struct psi_cpp *cpp, bool free_token)
fprintf(stderr, "NULL\n");
}
#endif
fprintf(stderr, "NULL\n");
}
#endif
- if (
cur &&
free_token) {
-
free(
cur);
+ if (free_token) {
+
psi_token_free(&
cur);
}
count = psi_plist_count(cpp->tokens);
if (deleted && cpp->index >= count) {
}
count = psi_plist_count(cpp->tokens);
if (deleted && cpp->index >= count) {
@@
-173,9
+173,7
@@
bool psi_cpp_tokiter_del_range(struct psi_cpp *cpp, size_t offset, size_t num_el
if (free_tokens) {
while (num_eles--) {
if (free_tokens) {
while (num_eles--) {
- if (ptr[num_eles]) {
- free(ptr[num_eles]);
- }
+ psi_token_free(&ptr[num_eles]);
}
free(ptr);
}
}
free(ptr);
}
@@
-260,16
+258,18
@@
static size_t psi_cpp_tokiter_expand_tokens(struct psi_cpp *cpp,
struct psi_token *tmp_tok, *old_tok = exp_tokens[n - 1];
tmp_tok = psi_token_init(old_tok->type, "", 0,
struct psi_token *tmp_tok, *old_tok = exp_tokens[n - 1];
tmp_tok = psi_token_init(old_tok->type, "", 0,
- target->col, target->line, target->file?:"");
+ target->col, target->line,
+ target->file ? target->file : zend_empty_string);
new_tok = psi_token_cat(NULL, 3, tmp_tok, old_tok, tok);
new_tok = psi_token_cat(NULL, 3, tmp_tok, old_tok, tok);
-
free(
old_tok);
-
free(
tmp_tok);
+
psi_token_free(&
old_tok);
+
psi_token_free(&
tmp_tok);
exp_tokens[n - 1] = new_tok;
} else {
new_tok = psi_token_init(stringify ? PSI_T_QUOTED_STRING : tok->type,
exp_tokens[n - 1] = new_tok;
} else {
new_tok = psi_token_init(stringify ? PSI_T_QUOTED_STRING : tok->type,
- tok->text, tok->size, target->col, target->line, target->file?:"");
+ tok->text->val, tok->text->len, target->col, target->line,
+ target->file ?: zend_empty_string);
exp_tokens[n++] = new_tok;
}
exp_tokens[n++] = new_tok;
}
@@
-301,7
+301,7
@@
static void psi_cpp_tokiter_free_call_tokens(struct psi_plist **arg_tokens_list,
struct psi_token *tok;
while (psi_plist_pop(arg_tokens_list[i], &tok)) {
struct psi_token *tok;
while (psi_plist_pop(arg_tokens_list[i], &tok)) {
-
free(
tok);
+
psi_token_free(&
tok);
}
}
psi_plist_free(arg_tokens_list[i]);
}
}
psi_plist_free(arg_tokens_list[i]);
@@
-395,11
+395,9
@@
static void psi_cpp_tokiter_expand_call_tokens(struct psi_cpp *cpp,
struct psi_token *arg_name;
for (s = 0; psi_plist_get(macro->sig, s, &arg_name); ++s) {
struct psi_token *arg_name;
for (s = 0; psi_plist_get(macro->sig, s, &arg_name); ++s) {
- if (arg_name->size == tok->size) {
- if (!memcmp(arg_name->text, tok->text, tok->size)) {
- arg_tokens = arg_tokens_list[s];
- break;
- }
+ if (zend_string_equals(arg_name->text, tok->text)) {
+ arg_tokens = arg_tokens_list[s];
+ break;
}
}
}
}
}
}
@@
-443,7
+441,7
@@
static bool psi_cpp_tokiter_expand_call(struct psi_cpp *cpp,
/* back to where we took off */
psi_cpp_tokiter_seek(cpp, start);
/* back to where we took off */
psi_cpp_tokiter_seek(cpp, start);
-
free(
target);
+
psi_token_free(&
target);
++cpp->expanded;
return true;
}
++cpp->expanded;
return true;
}
@@
-463,7
+461,7
@@
static bool psi_cpp_tokiter_expand_def(struct psi_cpp *cpp,
/* replace with tokens from macro */
psi_cpp_tokiter_expand_tokens(cpp, target, macro->tokens);
/* replace with tokens from macro */
psi_cpp_tokiter_expand_tokens(cpp, target, macro->tokens);
-
free(
target);
+
psi_token_free(&
target);
++cpp->expanded;
return true;
}
++cpp->expanded;
return true;
}
@@
-476,7
+474,7
@@
static inline int psi_cpp_tokiter_expand_cmp(struct psi_token *t,
psi_plist_get(m->tokens, 0, &r);
psi_plist_get(m->tokens, 0, &r);
- return
strcmp
(r->text, t->text);
+ return
!zend_string_equals
(r->text, t->text);
}
return -1;
}
}
return -1;
}
@@
-487,8
+485,8
@@
bool psi_cpp_tokiter_expand(struct psi_cpp *cpp)
struct psi_token *current = psi_cpp_tokiter_current(cpp);
if (current) {
struct psi_token *current = psi_cpp_tokiter_current(cpp);
if (current) {
- struct psi_cpp_macro_decl *macro = zend_hash_
str_
find_ptr(
- &cpp->defs, current->text
, current->size
);
+ struct psi_cpp_macro_decl *macro = zend_hash_find_ptr(
+ &cpp->defs, current->text);
/* don't expand itself */
if (macro && macro->token != current) {
/* don't expand itself */
if (macro && macro->token != current) {