Skip to content

Commit

Permalink
Do not restore stack too many times
Browse files Browse the repository at this point in the history
(cherry picked from commit 6e77ea7ce647b8e8f6f2b4c7855b50817636bf9d)
  • Loading branch information
sjinks committed Jul 25, 2013
1 parent e6dd0c6 commit fab2bec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions ext/kernel/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,20 +322,20 @@ void phalcon_inherit_not_found(const char *class_name, const char *inherit_name)
/**
* Parses method parameters with minimum overhead
*/
int phalcon_fetch_parameters(int grow_stack, int num_args TSRMLS_DC, int required_args, int optional_args, ...)
int phalcon_fetch_parameters(int num_args TSRMLS_DC, int required_args, int optional_args, ...)
{
va_list va;
int arg_count = (int) (zend_uintptr_t) *(zend_vm_stack_top(TSRMLS_C) - 1);
zval **arg, **p;
int i;

if (num_args < required_args || (num_args > (required_args + optional_args))) {
phalcon_throw_exception_string(spl_ce_BadMethodCallException, SL("Wrong number of parameters"), grow_stack TSRMLS_CC);
phalcon_throw_exception_string(spl_ce_BadMethodCallException, SL("Wrong number of parameters"), 0 TSRMLS_CC);
return FAILURE;
}

if (num_args > arg_count) {
phalcon_throw_exception_string(spl_ce_BadMethodCallException, SL("Could not obtain parameters for parsing"), grow_stack TSRMLS_CC);
phalcon_throw_exception_string(spl_ce_BadMethodCallException, SL("Could not obtain parameters for parsing"), 0 TSRMLS_CC);
return FAILURE;
}

Expand Down
4 changes: 2 additions & 2 deletions ext/kernel/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ extern void phalcon_inherit_not_found(const char *class_name, const char *inheri
extern int phalcon_is_iterable_ex(zval *arr, HashTable **arr_hash, HashPosition *hash_position, int duplicate, int reverse);

/* Fetch Parameters */
extern int phalcon_fetch_parameters(int grow_stack, int num_args TSRMLS_DC, int required_args, int optional_args, ...);
extern int phalcon_fetch_parameters(int num_args TSRMLS_DC, int required_args, int optional_args, ...);

/* Compatibility with PHP 5.3 */
#ifndef ZVAL_COPY_VALUE
Expand Down Expand Up @@ -316,7 +316,7 @@ extern int phalcon_fetch_parameters(int grow_stack, int num_args TSRMLS_DC, int

/** Low overhead parse/fetch parameters */
#define phalcon_fetch_params(memory_grow, required_params, optional_params, ...) \
if (phalcon_fetch_parameters(memory_grow, ZEND_NUM_ARGS() TSRMLS_CC, required_params, optional_params, __VA_ARGS__) == FAILURE) { \
if (phalcon_fetch_parameters(ZEND_NUM_ARGS() TSRMLS_CC, required_params, optional_params, __VA_ARGS__) == FAILURE) { \
if (memory_grow) { \
RETURN_MM_NULL(); \
} else { \
Expand Down

0 comments on commit fab2bec

Please sign in to comment.