Skip to content

Commit 6ade7d7

Browse files
committed
ext/session: remove PS_ENCODE_VARS
By moving the declaration of the variables inside PS_ENCODE_LOOP() macro.
1 parent dcf5cd9 commit 6ade7d7

2 files changed

Lines changed: 3 additions & 13 deletions

File tree

ext/session/php_session.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,26 +285,20 @@ PHPAPI zend_result php_session_reset_id(void);
285285
} \
286286
} while (0)
287287

288-
289-
#define PS_ENCODE_VARS \
290-
zend_string *key; \
291-
zend_ulong num_key; \
292-
zval *struc;
293-
294288
/* Do not use a return statement in `code` because that may leak memory.
295289
* Break out of the loop instead. */
296290
#define PS_ENCODE_LOOP(code) do { \
297291
zval _zv; \
298292
/* protect against user interference */ \
299293
ZVAL_COPY(&_zv, Z_REFVAL(PS(http_session_vars))); \
300-
HashTable *_ht = Z_ARRVAL(_zv); \
301-
ZEND_HASH_FOREACH_KEY(_ht, num_key, key) { \
294+
ZEND_HASH_FOREACH_KEY(Z_ARRVAL(_zv), zend_ulong num_key, zend_string * key) { \
302295
if (key == NULL) { \
303296
php_error_docref(NULL, E_WARNING, \
304297
"Skipping numeric key " ZEND_LONG_FMT, num_key);\
305298
continue; \
306299
} \
307-
if ((struc = php_get_session_var(key))) { \
300+
zval *struc = php_get_session_var(key); \
301+
if (struc) { \
308302
code; \
309303
} \
310304
} ZEND_HASH_FOREACH_END(); \

ext/session/session.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,6 @@ static void php_session_save_current_state(bool write)
567567

568568
static void php_session_normalize_vars(void)
569569
{
570-
PS_ENCODE_VARS;
571-
572570
IF_SESSION_VARS() {
573571
PS_ENCODE_LOOP(
574572
if (Z_TYPE_P(struc) == IS_PTR) {
@@ -988,7 +986,6 @@ PS_SERIALIZER_ENCODE_FUNC(php_binary)
988986
{
989987
smart_str buf = {0};
990988
php_serialize_data_t var_hash;
991-
PS_ENCODE_VARS;
992989

993990
PHP_VAR_SERIALIZE_INIT(var_hash);
994991

@@ -1052,7 +1049,6 @@ PS_SERIALIZER_ENCODE_FUNC(php)
10521049
smart_str buf = {0};
10531050
php_serialize_data_t var_hash;
10541051
bool fail = false;
1055-
PS_ENCODE_VARS;
10561052

10571053
PHP_VAR_SERIALIZE_INIT(var_hash);
10581054

0 commit comments

Comments
 (0)