Skip to content

Commit

Permalink
Use stack allocated zval here
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed Mar 3, 2013
1 parent caaf4e2 commit 585fad3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
9 changes: 3 additions & 6 deletions routes/yaf_route_regex.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ static zval * yaf_route_regex_match(yaf_route_t *route, char *uir, int len TSRML
if ((pce_regexp = pcre_get_compiled_regex_cache(Z_STRVAL_P(match), Z_STRLEN_P(match) TSRMLS_CC)) == NULL) {
return NULL;
} else {
zval *matches, *subparts, *map;
zval matches, *subparts, *map;

MAKE_STD_ZVAL(matches);
MAKE_STD_ZVAL(subparts);
ZVAL_NULL(subparts);

Expand All @@ -99,11 +98,10 @@ static zval * yaf_route_regex_match(yaf_route_t *route, char *uir, int len TSRML
map = NULL;
}

php_pcre_match_impl(pce_regexp, uir, len, matches, subparts /* subpats */,
php_pcre_match_impl(pce_regexp, uir, len, &matches, subparts /* subpats */,
0/* global */, 0/* ZEND_NUM_ARGS() >= 4 */, 0/*flags PREG_OFFSET_CAPTURE*/, 0/* start_offset */ TSRMLS_CC);

if (!Z_LVAL_P(matches)) {
zval_ptr_dtor(&matches);
if (!zend_hash_num_elements(Z_ARRVAL_P(subparts))) {
zval_ptr_dtor(&subparts);
return NULL;
} else {
Expand Down Expand Up @@ -136,7 +134,6 @@ static zval * yaf_route_regex_match(yaf_route_t *route, char *uir, int len TSRML
}
}

zval_ptr_dtor(&matches);
zval_ptr_dtor(&subparts);
return ret;
}
Expand Down
10 changes: 3 additions & 7 deletions routes/yaf_route_rewrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,17 @@ static zval * yaf_route_rewrite_match(yaf_route_t *router, char *uir, int len TS
smart_str_free(&pattern);
return NULL;
} else {
zval *matches, *subparts;
zval matches, *subparts;

smart_str_free(&pattern);

MAKE_STD_ZVAL(matches);
MAKE_STD_ZVAL(subparts);
ZVAL_LONG(matches, 0);
ZVAL_NULL(subparts);

php_pcre_match_impl(pce_regexp, uir, len, matches, subparts /* subpats */,
php_pcre_match_impl(pce_regexp, uir, len, &matches, subparts /* subpats */,
0/* global */, 0/* ZEND_NUM_ARGS() >= 4 */, 0/*flags PREG_OFFSET_CAPTURE*/, 0/* start_offset */ TSRMLS_CC);

if (!Z_LVAL_P(matches)) {
zval_ptr_dtor(&matches);
if (!zend_hash_num_elements(Z_ARRVAL_P(subparts))) {
zval_ptr_dtor(&subparts);
return NULL;
} else {
Expand Down Expand Up @@ -172,7 +169,6 @@ static zval * yaf_route_rewrite_match(yaf_route_t *router, char *uir, int len TS
}
}

zval_ptr_dtor(&matches);
zval_ptr_dtor(&subparts);
return ret;
}
Expand Down

0 comments on commit 585fad3

Please sign in to comment.