From 7120818f0d153570d1929ed0d1d8b7c165e321bd Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Wed, 25 Jan 2017 22:08:43 -0800 Subject: [PATCH 1/5] Begin replacing zend_parse_parameters with the fast_zpp API --- php_memcached.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/php_memcached.c b/php_memcached.c index 19673323..de6f2e5a 100644 --- a/php_memcached.c +++ b/php_memcached.c @@ -2162,21 +2162,31 @@ static void php_memc_incdec_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key, { zend_string *key, *server_key = NULL; zend_long offset = 1; - uint64_t value = UINT64_MAX, initial = 0; - time_t expiry = 0; + zend_long expiry = 0; + zend_long initial = 0; + uint64_t value = UINT64_MAX; memcached_return status; int n_args = ZEND_NUM_ARGS(); MEMC_METHOD_INIT_VARS; if (!by_key) { - if (zend_parse_parameters(n_args, "S|lll", &key, &offset, &initial, &expiry) == FAILURE) { - return; - } + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STR(key) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(offset) + Z_PARAM_LONG(initial) + Z_PARAM_LONG(expiry) + ZEND_PARSE_PARAMETERS_END(); } else { - if (zend_parse_parameters(n_args, "SS|lll", &server_key, &key, &offset, &initial, &expiry) == FAILURE) { - return; - } + ZEND_PARSE_PARAMETERS_START(2, 5) + Z_PARAM_STR(server_key) + Z_PARAM_STR(key) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(offset) + Z_PARAM_LONG(initial) + Z_PARAM_LONG(expiry) + ZEND_PARSE_PARAMETERS_END(); } MEMC_METHOD_FETCH_OBJECT; @@ -2218,15 +2228,15 @@ static void php_memc_incdec_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key, } if (by_key) { if (incr) { - status = memcached_increment_with_initial_by_key(intern->memc, ZSTR_VAL(server_key), ZSTR_LEN(server_key), ZSTR_VAL(key), ZSTR_LEN(key), offset, initial, expiry, &value); + status = memcached_increment_with_initial_by_key(intern->memc, ZSTR_VAL(server_key), ZSTR_LEN(server_key), ZSTR_VAL(key), ZSTR_LEN(key), offset, initial, (time_t)expiry, &value); } else { - status = memcached_decrement_with_initial_by_key(intern->memc, ZSTR_VAL(server_key), ZSTR_LEN(server_key), ZSTR_VAL(key), ZSTR_LEN(key), offset, initial, expiry, &value); + status = memcached_decrement_with_initial_by_key(intern->memc, ZSTR_VAL(server_key), ZSTR_LEN(server_key), ZSTR_VAL(key), ZSTR_LEN(key), offset, initial, (time_t)expiry, &value); } } else { if (incr) { - status = memcached_increment_with_initial(intern->memc, ZSTR_VAL(key), ZSTR_LEN(key), offset, initial, expiry, &value); + status = memcached_increment_with_initial(intern->memc, ZSTR_VAL(key), ZSTR_LEN(key), offset, initial, (time_t)expiry, &value); } else { - status = memcached_decrement_with_initial(intern->memc, ZSTR_VAL(key), ZSTR_LEN(key), offset, initial, expiry, &value); + status = memcached_decrement_with_initial(intern->memc, ZSTR_VAL(key), ZSTR_LEN(key), offset, initial, (time_t)expiry, &value); } } if (s_should_retry_write(intern, status) && retries-- > 0) { From e236c039cb48475733b11ce1161d6a76aec4a88c Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Mon, 30 Jan 2017 23:25:08 -0800 Subject: [PATCH 2/5] Another round of conversions to new fast_zpp --- php_memcached.c | 146 +++++++++++++++++++++++++++++++----------------- 1 file changed, 96 insertions(+), 50 deletions(-) diff --git a/php_memcached.c b/php_memcached.c index de6f2e5a..a8e3a1aa 100644 --- a/php_memcached.c +++ b/php_memcached.c @@ -1174,9 +1174,12 @@ static PHP_METHOD(Memcached, __construct) zend_bool is_persistent = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S!f!S", &persistent_id, &fci, &fci_cache, &conn_str) == FAILURE) { - return; - } + ZEND_PARSE_PARAMETERS_START(0, 3) + Z_PARAM_OPTIONAL + Z_PARAM_STR_EX(persistent_id, 0, 1) + Z_PARAM_FUNC_EX(fci, fci_cache, 0, 1) + Z_PARAM_STR(conn_str) + ZEND_PARSE_PARAMETERS_END(); intern = Z_MEMC_OBJ_P(getThis()); intern->is_pristine = 1; @@ -1403,13 +1406,20 @@ void php_memc_get_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key) MEMC_METHOD_INIT_VARS; if (by_key) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|f!l", &server_key, &key, &fci, &fcc, &get_flags) == FAILURE) { - return; - } + ZEND_PARSE_PARAMETERS_START(2, 5) + Z_PARAM_STR(server_key) + Z_PARAM_STR(key) + Z_PARAM_OPTIONAL + Z_PARAM_FUNC_EX(fci, fcc, 0, 1) + Z_PARAM_LONG(get_flags) + ZEND_PARSE_PARAMETERS_END(); } else { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|f!l", &key, &fci, &fcc, &get_flags) == FAILURE) { - return; - } + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STR(key) + Z_PARAM_OPTIONAL + Z_PARAM_FUNC_EX(fci, fcc, 0, 1) + Z_PARAM_LONG(get_flags) + ZEND_PARSE_PARAMETERS_END(); } MEMC_METHOD_FETCH_OBJECT; @@ -1495,14 +1505,18 @@ static void php_memc_getMulti_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_ke zend_bool retval, preserve_order; if (by_key) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sa|l", &server_key, - &keys, &flags) == FAILURE) { - return; - } + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(server_key) + Z_PARAM_ARRAY(keys) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(flags) + ZEND_PARSE_PARAMETERS_END(); } else { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "a|l", &keys, &flags) == FAILURE) { - return; - } + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(keys) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(flags) + ZEND_PARSE_PARAMETERS_END(); } MEMC_METHOD_FETCH_OBJECT; @@ -1632,15 +1646,20 @@ static void php_memc_getDelayed_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_ if (by_key) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sa/|bf!", &server_key, - &keys, &with_cas, &fci, &fcc) == FAILURE) { - return; - } + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_STR(server_key) + Z_PARAM_ARRAY(keys) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(with_cas) + Z_PARAM_FUNC_EX(fci, fcc, 0, 1) + ZEND_PARSE_PARAMETERS_END(); } else { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "a/|bf!", &keys, &with_cas, - &fci, &fcc) == FAILURE) { - return; - } + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ARRAY(keys) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(with_cas) + Z_PARAM_FUNC_EX(fci, fcc, 0, 1) + ZEND_PARSE_PARAMETERS_END(); } MEMC_METHOD_FETCH_OBJECT; @@ -1786,7 +1805,7 @@ static void php_memc_setMulti_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_ke { zval *entries; zend_string *server_key = NULL; - time_t expiration = 0; + zend_long expiration = 0, ignored; zval *value; zend_string *skey; zend_ulong num_key; @@ -1794,14 +1813,20 @@ static void php_memc_setMulti_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_ke MEMC_METHOD_INIT_VARS; if (by_key) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sa|ll", &server_key, - &entries, &expiration) == FAILURE) { - return; - } + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_STR(server_key) + Z_PARAM_ARRAY(entries) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(expiration) + Z_PARAM_LONG(ignored) + ZEND_PARSE_PARAMETERS_END(); } else { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "a|ll", &entries, &expiration) == FAILURE) { - return; - } + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ARRAY(entries) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(expiration) + Z_PARAM_LONG(ignored) + ZEND_PARSE_PARAMETERS_END(); } MEMC_METHOD_FETCH_OBJECT; @@ -1911,35 +1936,56 @@ static void php_memc_store_impl(INTERNAL_FUNCTION_PARAMETERS, int op, zend_bool if (by_key) { if (op == MEMC_OP_APPEND || op == MEMC_OP_PREPEND) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "SSS", &server_key, &key, &s_value) == FAILURE) { - return; - } + /* "SSS" */ + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(server_key) + Z_PARAM_STR(key) + Z_PARAM_STR(s_value) + ZEND_PARSE_PARAMETERS_END(); value = &s_zvalue; ZVAL_STR(value, s_value); } else if (op == MEMC_OP_TOUCH) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|l", &server_key, &key, &expiration) == FAILURE) { - return; - } + /* "SS|l" */ + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(server_key) + Z_PARAM_STR(key) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(expiration) + ZEND_PARSE_PARAMETERS_END(); } else { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "SSz|l", &server_key, &key, &value, &expiration) == FAILURE) { - return; - } + /* "SSz|l" */ + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_STR(server_key) + Z_PARAM_STR(key) + Z_PARAM_ZVAL(value) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(expiration) + ZEND_PARSE_PARAMETERS_END(); } } else { if (op == MEMC_OP_APPEND || op == MEMC_OP_PREPEND) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS", &key, &s_value) == FAILURE) { - return; - } + /* "SS" */ + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(key) + Z_PARAM_STR(s_value) + ZEND_PARSE_PARAMETERS_END(); value = &s_zvalue; ZVAL_STR(value, s_value); } else if (op == MEMC_OP_TOUCH) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|l", &key, &expiration) == FAILURE) { - return; - } + /* "S|l */ + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(key) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(expiration) + ZEND_PARSE_PARAMETERS_END(); } else { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sz|l", &key, &value, &expiration) == FAILURE) { - return; - } + /* "Sz|l" */ + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(key) + Z_PARAM_ZVAL(value) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(expiration) + ZEND_PARSE_PARAMETERS_END(); } } From 2760e2eb02c31363d211b9307f7d779e5fdd7b43 Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Mon, 30 Jan 2017 23:32:49 -0800 Subject: [PATCH 3/5] Fix the translation of zpp("f!") to Z_PARAM_FUNC_EX(fci, fcc, 1, 0) --- php_memcached.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/php_memcached.c b/php_memcached.c index a8e3a1aa..8e80ea53 100644 --- a/php_memcached.c +++ b/php_memcached.c @@ -1176,8 +1176,8 @@ static PHP_METHOD(Memcached, __construct) ZEND_PARSE_PARAMETERS_START(0, 3) Z_PARAM_OPTIONAL - Z_PARAM_STR_EX(persistent_id, 0, 1) - Z_PARAM_FUNC_EX(fci, fci_cache, 0, 1) + Z_PARAM_STR_EX(persistent_id, 1, 0) + Z_PARAM_FUNC_EX(fci, fci_cache, 1, 0) Z_PARAM_STR(conn_str) ZEND_PARSE_PARAMETERS_END(); @@ -1410,14 +1410,14 @@ void php_memc_get_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key) Z_PARAM_STR(server_key) Z_PARAM_STR(key) Z_PARAM_OPTIONAL - Z_PARAM_FUNC_EX(fci, fcc, 0, 1) + Z_PARAM_FUNC_EX(fci, fcc, 1, 0) Z_PARAM_LONG(get_flags) ZEND_PARSE_PARAMETERS_END(); } else { ZEND_PARSE_PARAMETERS_START(1, 4) Z_PARAM_STR(key) Z_PARAM_OPTIONAL - Z_PARAM_FUNC_EX(fci, fcc, 0, 1) + Z_PARAM_FUNC_EX(fci, fcc, 1, 0) Z_PARAM_LONG(get_flags) ZEND_PARSE_PARAMETERS_END(); } @@ -1651,14 +1651,14 @@ static void php_memc_getDelayed_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_ Z_PARAM_ARRAY(keys) Z_PARAM_OPTIONAL Z_PARAM_BOOL(with_cas) - Z_PARAM_FUNC_EX(fci, fcc, 0, 1) + Z_PARAM_FUNC_EX(fci, fcc, 1, 0) ZEND_PARSE_PARAMETERS_END(); } else { ZEND_PARSE_PARAMETERS_START(1, 3) Z_PARAM_ARRAY(keys) Z_PARAM_OPTIONAL Z_PARAM_BOOL(with_cas) - Z_PARAM_FUNC_EX(fci, fcc, 0, 1) + Z_PARAM_FUNC_EX(fci, fcc, 1, 0) ZEND_PARSE_PARAMETERS_END(); } From 5f28ffe3785cc581c20a3e6bbec90163425f7e0f Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Sat, 4 Feb 2017 04:43:34 -0800 Subject: [PATCH 4/5] The rest of the fast_zpp conversions --- php_memcached.c | 184 +++++++++++++++++++++++++++++++----------------- 1 file changed, 118 insertions(+), 66 deletions(-) diff --git a/php_memcached.c b/php_memcached.c index 8e80ea53..0253a142 100644 --- a/php_memcached.c +++ b/php_memcached.c @@ -1174,6 +1174,7 @@ static PHP_METHOD(Memcached, __construct) zend_bool is_persistent = 0; + /* |S!f!S */ ZEND_PARSE_PARAMETERS_START(0, 3) Z_PARAM_OPTIONAL Z_PARAM_STR_EX(persistent_id, 1, 0) @@ -1406,7 +1407,8 @@ void php_memc_get_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key) MEMC_METHOD_INIT_VARS; if (by_key) { - ZEND_PARSE_PARAMETERS_START(2, 5) + /* SS|f!l */ + ZEND_PARSE_PARAMETERS_START(2, 4) Z_PARAM_STR(server_key) Z_PARAM_STR(key) Z_PARAM_OPTIONAL @@ -1414,7 +1416,8 @@ void php_memc_get_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key) Z_PARAM_LONG(get_flags) ZEND_PARSE_PARAMETERS_END(); } else { - ZEND_PARSE_PARAMETERS_START(1, 4) + /* S|f!l */ + ZEND_PARSE_PARAMETERS_START(1, 3) Z_PARAM_STR(key) Z_PARAM_OPTIONAL Z_PARAM_FUNC_EX(fci, fcc, 1, 0) @@ -2020,22 +2023,34 @@ static void php_memc_cas_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key) zend_string *key; zend_string *server_key = NULL; zval *value; - time_t expiration = 0; + zend_long expiration = 0; + zend_long ignored; zend_string *payload; uint32_t flags = 0; memcached_return status; MEMC_METHOD_INIT_VARS; if (by_key) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "zSSz|ll", &zv_cas, &server_key, &key, - &value, &expiration) == FAILURE) { - return; - } + /* zSSz|ll */ + ZEND_PARSE_PARAMETERS_START(4, 6) + Z_PARAM_ZVAL(zv_cas) + Z_PARAM_STR(server_key) + Z_PARAM_STR(key) + Z_PARAM_ZVAL(value) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(expiration) + Z_PARAM_LONG(ignored) + ZEND_PARSE_PARAMETERS_END(); } else { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "zSz|ll", &zv_cas, &key, &value, - &expiration) == FAILURE) { - return; - } + /* zSz|ll */ + ZEND_PARSE_PARAMETERS_START(3, 5) + Z_PARAM_ZVAL(zv_cas) + Z_PARAM_STR(key) + Z_PARAM_ZVAL(value) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(expiration) + Z_PARAM_LONG(ignored) + ZEND_PARSE_PARAMETERS_END(); } MEMC_METHOD_FETCH_OBJECT; @@ -2117,18 +2132,25 @@ PHP_METHOD(Memcached, deleteMultiByKey) static void php_memc_delete_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key) { zend_string *key, *server_key; - time_t expiration = 0; + zend_long expiration = 0; memcached_return status; MEMC_METHOD_INIT_VARS; if (by_key) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|l", &server_key, &key, &expiration) == FAILURE) { - return; - } + /* SS|l */ + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(server_key) + Z_PARAM_STR(key) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(expiration) + ZEND_PARSE_PARAMETERS_END(); } else { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "S|l", &key, &expiration) == FAILURE) { - return; - } + /* S|l */ + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(key) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(expiration) + ZEND_PARSE_PARAMETERS_END(); server_key = key; } @@ -2156,20 +2178,27 @@ static void php_memc_deleteMulti_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by { zval *entries, *zv, ret; zend_string *server_key = NULL; - time_t expiration = 0; + zend_long expiration = 0; zend_string *entry; memcached_return status; MEMC_METHOD_INIT_VARS; if (by_key) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sa/|l", &server_key, &entries, &expiration) == FAILURE) { - return; - } + /* Sa/|l */ + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(server_key) + Z_PARAM_ARRAY_EX(entries, 0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(expiration) + ZEND_PARSE_PARAMETERS_END(); } else { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "a/|l", &entries, &expiration) == FAILURE) { - return; - } + /* a/|l */ + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY_EX(entries, 0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(expiration) + ZEND_PARSE_PARAMETERS_END(); } MEMC_METHOD_FETCH_OBJECT; @@ -2339,13 +2368,17 @@ PHP_METHOD(Memcached, incrementByKey) PHP_METHOD(Memcached, addServer) { zend_string *host; - long port, weight = 0; + zend_long port, weight = 0; memcached_return status; MEMC_METHOD_INIT_VARS; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "Sl|l", &host, &port, &weight) == FAILURE) { - return; - } + /* Sa/|l */ + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(host) + Z_PARAM_LONG(port) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(weight) + ZEND_PARSE_PARAMETERS_END(); MEMC_METHOD_FETCH_OBJECT; s_memc_set_status(intern, MEMCACHED_SUCCESS, 0); @@ -2373,9 +2406,10 @@ PHP_METHOD(Memcached, addServers) memcached_return status; MEMC_METHOD_INIT_VARS; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "a/", &servers) == FAILURE) { - return; - } + /* a/ */ + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY_EX(servers, 0, 1) + ZEND_PARSE_PARAMETERS_END(); MEMC_METHOD_FETCH_OBJECT; s_memc_set_status(intern, MEMCACHED_SUCCESS, 0); @@ -2477,9 +2511,10 @@ PHP_METHOD(Memcached, getServerByKey) memcached_return error; MEMC_METHOD_INIT_VARS; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &server_key) == FAILURE) { - return; - } + /* S */ + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(server_key) + ZEND_PARSE_PARAMETERS_END(); MEMC_METHOD_FETCH_OBJECT; s_memc_set_status(intern, MEMCACHED_SUCCESS, 0); @@ -2697,9 +2732,11 @@ PHP_METHOD(Memcached, getStats) zend_string *args_string = NULL; MEMC_METHOD_INIT_VARS; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|S!", &args_string) == FAILURE) { - return; - } + /* |S! */ + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_EX(args_string, 1, 0) + ZEND_PARSE_PARAMETERS_END(); MEMC_METHOD_FETCH_OBJECT; @@ -2791,13 +2828,15 @@ PHP_METHOD(Memcached, getAllKeys) Flushes the data on all the servers */ static PHP_METHOD(Memcached, flush) { - time_t delay = 0; + zend_long delay = 0; memcached_return status; MEMC_METHOD_INIT_VARS; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &delay) == FAILURE) { - return; - } + /* |l */ + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(delay) + ZEND_PARSE_PARAMETERS_END(); MEMC_METHOD_FETCH_OBJECT; s_memc_set_status(intern, MEMCACHED_SUCCESS, 0); @@ -2815,14 +2854,15 @@ static PHP_METHOD(Memcached, flush) Returns the value for the given option constant */ static PHP_METHOD(Memcached, getOption) { - long option; + zend_long option; uint64_t result; memcached_behavior flag; MEMC_METHOD_INIT_VARS; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &option) == FAILURE) { - return; - } + /* l */ + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(option) + ZEND_PARSE_PARAMETERS_END(); MEMC_METHOD_FETCH_OBJECT; @@ -3064,7 +3104,7 @@ PHP_METHOD(Memcached, setBucket) { zval *zserver_map; zval *zforward_map = NULL; - long replicas = 0; + zend_long replicas = 0; zend_bool retval = 1; uint32_t *server_map = NULL, *forward_map = NULL; @@ -3072,9 +3112,12 @@ PHP_METHOD(Memcached, setBucket) memcached_return rc; MEMC_METHOD_INIT_VARS; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "aa!l", &zserver_map, &zforward_map, &replicas) == FAILURE) { - return; - } + /* aa!l */ + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ARRAY(zserver_map) + Z_PARAM_ARRAY_EX(zforward_map, 1, 0) + Z_PARAM_LONG(replicas) + ZEND_PARSE_PARAMETERS_END(); MEMC_METHOD_FETCH_OBJECT; @@ -3135,9 +3178,11 @@ static PHP_METHOD(Memcached, setOptions) MEMC_METHOD_INIT_VARS; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "a", &options) == FAILURE) { - return; - } + /* a */ + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + MEMC_METHOD_FETCH_OBJECT; @@ -3160,13 +3205,15 @@ static PHP_METHOD(Memcached, setOptions) Sets the value for the given option constant */ static PHP_METHOD(Memcached, setOption) { - long option; + zend_long option; zval *value; MEMC_METHOD_INIT_VARS; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz/", &option, &value) == FAILURE) { - return; - } + /* lz/ */ + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_LONG(option) + Z_PARAM_ZVAL_EX(value, 0, 1) + ZEND_PARSE_PARAMETERS_END(); MEMC_METHOD_FETCH_OBJECT; @@ -3183,9 +3230,11 @@ static PHP_METHOD(Memcached, setSaslAuthData) memcached_return status; zend_string *user, *pass; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS", &user, &pass) == FAILURE) { - return; - } + /* SS/ */ + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(user) + Z_PARAM_STR(pass) + ZEND_PARSE_PARAMETERS_END(); if (!php_memc_init_sasl_if_needed()) { RETURN_FALSE; @@ -3667,9 +3716,10 @@ PHP_METHOD(MemcachedServer, run) php_memc_server_t *intern; intern = Z_MEMC_SERVER_P(getThis()); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &address) == FAILURE) { - return; - } + /* S */ + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(address) + ZEND_PARSE_PARAMETERS_END(); rc = php_memc_proto_handler_run(intern->handler, address); @@ -3688,9 +3738,11 @@ PHP_METHOD(MemcachedServer, on) zend_fcall_info_cache fci_cache; zend_bool rc = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "lf!", &event, &fci, &fci_cache) == FAILURE) { - return; - } + /* lf! */ + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_LONG(event) + Z_PARAM_FUNC_EX(fci, fci_cache, 1, 0) + ZEND_PARSE_PARAMETERS_END(); if (event <= MEMC_SERVER_ON_MIN || event >= MEMC_SERVER_ON_MAX) { RETURN_FALSE; From cdffc9e153666978281443b186a7a67109b8e635 Mon Sep 17 00:00:00 2001 From: Aaron Stone Date: Sat, 4 Feb 2017 04:58:15 -0800 Subject: [PATCH 5/5] Minors --- php_memcached.c | 54 ++++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/php_memcached.c b/php_memcached.c index 0253a142..8ad4da20 100644 --- a/php_memcached.c +++ b/php_memcached.c @@ -1174,7 +1174,7 @@ static PHP_METHOD(Memcached, __construct) zend_bool is_persistent = 0; - /* |S!f!S */ + /* "|S!f!S" */ ZEND_PARSE_PARAMETERS_START(0, 3) Z_PARAM_OPTIONAL Z_PARAM_STR_EX(persistent_id, 1, 0) @@ -1407,7 +1407,7 @@ void php_memc_get_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key) MEMC_METHOD_INIT_VARS; if (by_key) { - /* SS|f!l */ + /* "SS|f!l" */ ZEND_PARSE_PARAMETERS_START(2, 4) Z_PARAM_STR(server_key) Z_PARAM_STR(key) @@ -1416,7 +1416,7 @@ void php_memc_get_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key) Z_PARAM_LONG(get_flags) ZEND_PARSE_PARAMETERS_END(); } else { - /* S|f!l */ + /* "S|f!l" */ ZEND_PARSE_PARAMETERS_START(1, 3) Z_PARAM_STR(key) Z_PARAM_OPTIONAL @@ -1508,6 +1508,7 @@ static void php_memc_getMulti_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_ke zend_bool retval, preserve_order; if (by_key) { + /* "Sa|l" */ ZEND_PARSE_PARAMETERS_START(2, 3) Z_PARAM_STR(server_key) Z_PARAM_ARRAY(keys) @@ -1515,6 +1516,7 @@ static void php_memc_getMulti_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_ke Z_PARAM_LONG(flags) ZEND_PARSE_PARAMETERS_END(); } else { + /* "a|l" */ ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_ARRAY(keys) Z_PARAM_OPTIONAL @@ -1649,16 +1651,18 @@ static void php_memc_getDelayed_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_ if (by_key) { + /* "Sa/|bf!" */ ZEND_PARSE_PARAMETERS_START(2, 4) Z_PARAM_STR(server_key) - Z_PARAM_ARRAY(keys) + Z_PARAM_ARRAY_EX(keys, 0, 1) Z_PARAM_OPTIONAL Z_PARAM_BOOL(with_cas) Z_PARAM_FUNC_EX(fci, fcc, 1, 0) ZEND_PARSE_PARAMETERS_END(); } else { + /* "a/|bf!" */ ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ARRAY(keys) + Z_PARAM_ARRAY_EX(keys, 0, 1) Z_PARAM_OPTIONAL Z_PARAM_BOOL(with_cas) Z_PARAM_FUNC_EX(fci, fcc, 1, 0) @@ -1816,6 +1820,7 @@ static void php_memc_setMulti_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_ke MEMC_METHOD_INIT_VARS; if (by_key) { + /* "Sa|ll" */ ZEND_PARSE_PARAMETERS_START(2, 4) Z_PARAM_STR(server_key) Z_PARAM_ARRAY(entries) @@ -1824,6 +1829,7 @@ static void php_memc_setMulti_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_ke Z_PARAM_LONG(ignored) ZEND_PARSE_PARAMETERS_END(); } else { + /* "a|ll" */ ZEND_PARSE_PARAMETERS_START(1, 3) Z_PARAM_ARRAY(entries) Z_PARAM_OPTIONAL @@ -2031,7 +2037,7 @@ static void php_memc_cas_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key) MEMC_METHOD_INIT_VARS; if (by_key) { - /* zSSz|ll */ + /* "zSSz|ll" */ ZEND_PARSE_PARAMETERS_START(4, 6) Z_PARAM_ZVAL(zv_cas) Z_PARAM_STR(server_key) @@ -2042,7 +2048,7 @@ static void php_memc_cas_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key) Z_PARAM_LONG(ignored) ZEND_PARSE_PARAMETERS_END(); } else { - /* zSz|ll */ + /* "zSz|ll" */ ZEND_PARSE_PARAMETERS_START(3, 5) Z_PARAM_ZVAL(zv_cas) Z_PARAM_STR(key) @@ -2137,7 +2143,7 @@ static void php_memc_delete_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key) MEMC_METHOD_INIT_VARS; if (by_key) { - /* SS|l */ + /* "SS|l" */ ZEND_PARSE_PARAMETERS_START(2, 3) Z_PARAM_STR(server_key) Z_PARAM_STR(key) @@ -2145,7 +2151,7 @@ static void php_memc_delete_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key) Z_PARAM_LONG(expiration) ZEND_PARSE_PARAMETERS_END(); } else { - /* S|l */ + /* "S|l" */ ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_STR(key) Z_PARAM_OPTIONAL @@ -2185,7 +2191,7 @@ static void php_memc_deleteMulti_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by MEMC_METHOD_INIT_VARS; if (by_key) { - /* Sa/|l */ + /* "Sa/|l" */ ZEND_PARSE_PARAMETERS_START(2, 3) Z_PARAM_STR(server_key) Z_PARAM_ARRAY_EX(entries, 0, 1) @@ -2193,7 +2199,7 @@ static void php_memc_deleteMulti_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by Z_PARAM_LONG(expiration) ZEND_PARSE_PARAMETERS_END(); } else { - /* a/|l */ + /* "a/|l" */ ZEND_PARSE_PARAMETERS_START(1, 2) Z_PARAM_ARRAY_EX(entries, 0, 1) Z_PARAM_OPTIONAL @@ -2246,6 +2252,7 @@ static void php_memc_incdec_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key, MEMC_METHOD_INIT_VARS; if (!by_key) { + /* "S|lll" */ ZEND_PARSE_PARAMETERS_START(1, 4) Z_PARAM_STR(key) Z_PARAM_OPTIONAL @@ -2254,6 +2261,7 @@ static void php_memc_incdec_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool by_key, Z_PARAM_LONG(expiry) ZEND_PARSE_PARAMETERS_END(); } else { + /* "SS|lll" */ ZEND_PARSE_PARAMETERS_START(2, 5) Z_PARAM_STR(server_key) Z_PARAM_STR(key) @@ -2372,7 +2380,7 @@ PHP_METHOD(Memcached, addServer) memcached_return status; MEMC_METHOD_INIT_VARS; - /* Sa/|l */ + /* "Sa/|l" */ ZEND_PARSE_PARAMETERS_START(2, 3) Z_PARAM_STR(host) Z_PARAM_LONG(port) @@ -2406,7 +2414,7 @@ PHP_METHOD(Memcached, addServers) memcached_return status; MEMC_METHOD_INIT_VARS; - /* a/ */ + /* "a/" */ ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ARRAY_EX(servers, 0, 1) ZEND_PARSE_PARAMETERS_END(); @@ -2511,7 +2519,7 @@ PHP_METHOD(Memcached, getServerByKey) memcached_return error; MEMC_METHOD_INIT_VARS; - /* S */ + /* "S" */ ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(server_key) ZEND_PARSE_PARAMETERS_END(); @@ -2732,7 +2740,7 @@ PHP_METHOD(Memcached, getStats) zend_string *args_string = NULL; MEMC_METHOD_INIT_VARS; - /* |S! */ + /* "|S!" */ ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL Z_PARAM_STR_EX(args_string, 1, 0) @@ -2832,7 +2840,7 @@ static PHP_METHOD(Memcached, flush) memcached_return status; MEMC_METHOD_INIT_VARS; - /* |l */ + /* "|l" */ ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL Z_PARAM_LONG(delay) @@ -2859,7 +2867,7 @@ static PHP_METHOD(Memcached, getOption) memcached_behavior flag; MEMC_METHOD_INIT_VARS; - /* l */ + /* "l" */ ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_LONG(option) ZEND_PARSE_PARAMETERS_END(); @@ -3112,7 +3120,7 @@ PHP_METHOD(Memcached, setBucket) memcached_return rc; MEMC_METHOD_INIT_VARS; - /* aa!l */ + /* "aa!l" */ ZEND_PARSE_PARAMETERS_START(3, 3) Z_PARAM_ARRAY(zserver_map) Z_PARAM_ARRAY_EX(zforward_map, 1, 0) @@ -3178,7 +3186,7 @@ static PHP_METHOD(Memcached, setOptions) MEMC_METHOD_INIT_VARS; - /* a */ + /* "a" */ ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); @@ -3209,7 +3217,7 @@ static PHP_METHOD(Memcached, setOption) zval *value; MEMC_METHOD_INIT_VARS; - /* lz/ */ + /* "lz/" */ ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_LONG(option) Z_PARAM_ZVAL_EX(value, 0, 1) @@ -3230,7 +3238,7 @@ static PHP_METHOD(Memcached, setSaslAuthData) memcached_return status; zend_string *user, *pass; - /* SS/ */ + /* "SS/" */ ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_STR(user) Z_PARAM_STR(pass) @@ -3716,7 +3724,7 @@ PHP_METHOD(MemcachedServer, run) php_memc_server_t *intern; intern = Z_MEMC_SERVER_P(getThis()); - /* S */ + /* "S" */ ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(address) ZEND_PARSE_PARAMETERS_END(); @@ -3738,7 +3746,7 @@ PHP_METHOD(MemcachedServer, on) zend_fcall_info_cache fci_cache; zend_bool rc = 0; - /* lf! */ + /* "lf!" */ ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_LONG(event) Z_PARAM_FUNC_EX(fci, fci_cache, 1, 0)