Skip to content

Commit 5188842

Browse files
committed
Drop struct union as access is now always named
1 parent 2ddd68a commit 5188842

File tree

3 files changed

+39
-43
lines changed

3 files changed

+39
-43
lines changed

ext/session/mod_user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static void ps_call_handler(zval *func, int argc, zval *argv, zval *retval)
4949
zval retval; \
5050
zend_result ret = FAILURE
5151

52-
#define PSF(a) PS(mod_user_names).name.ps_##a
52+
#define PSF(a) PS(mod_user_names).ps_##a
5353

5454
#define FINISH \
5555
if (Z_TYPE(retval) != IS_UNDEF) { \

ext/session/php_session.h

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#define PHP_SESSION_VERSION PHP_VERSION
2727

2828
/* save handler macros */
29-
#define PS_NUM_APIS 9
3029
#define PS_OPEN_ARGS void **mod_data, const char *save_path, const char *session_name
3130
#define PS_CLOSE_ARGS void **mod_data
3231
#define PS_READ_ARGS void **mod_data, zend_string *key, zend_string **val, zend_long maxlifetime
@@ -160,19 +159,16 @@ typedef struct _php_ps_globals {
160159
zend_long gc_maxlifetime;
161160
int module_number;
162161
zend_long cache_expire;
163-
union {
164-
zval names[PS_NUM_APIS];
165-
struct {
166-
zval ps_open;
167-
zval ps_close;
168-
zval ps_read;
169-
zval ps_write;
170-
zval ps_destroy;
171-
zval ps_gc;
172-
zval ps_create_sid;
173-
zval ps_validate_sid;
174-
zval ps_update_timestamp;
175-
} name;
162+
struct {
163+
zval ps_open;
164+
zval ps_close;
165+
zval ps_read;
166+
zval ps_write;
167+
zval ps_destroy;
168+
zval ps_gc;
169+
zval ps_create_sid;
170+
zval ps_validate_sid;
171+
zval ps_update_timestamp;
176172
} mod_user_names;
177173
bool mod_user_implemented;
178174
bool mod_user_is_open;

ext/session/session.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,31 +1951,31 @@ static inline void set_user_save_handler_ini(void) {
19511951
}
19521952

19531953
#define SESSION_RELEASE_USER_HANDLER_OO(struct_name) \
1954-
if (!Z_ISUNDEF(PS(mod_user_names).name.struct_name)) { \
1955-
zval_ptr_dtor(&PS(mod_user_names).name.struct_name); \
1956-
ZVAL_UNDEF(&PS(mod_user_names).name.struct_name); \
1954+
if (!Z_ISUNDEF(PS(mod_user_names).struct_name)) { \
1955+
zval_ptr_dtor(&PS(mod_user_names).struct_name); \
1956+
ZVAL_UNDEF(&PS(mod_user_names).struct_name); \
19571957
}
19581958

19591959
#define SESSION_SET_USER_HANDLER_OO(struct_name, zstr_method_name) \
1960-
array_init_size(&PS(mod_user_names).name.struct_name, 2); \
1960+
array_init_size(&PS(mod_user_names).struct_name, 2); \
19611961
Z_ADDREF_P(obj); \
1962-
add_next_index_zval(&PS(mod_user_names).name.struct_name, obj); \
1963-
add_next_index_str(&PS(mod_user_names).name.struct_name, zstr_method_name);
1962+
add_next_index_zval(&PS(mod_user_names).struct_name, obj); \
1963+
add_next_index_str(&PS(mod_user_names).struct_name, zstr_method_name);
19641964

19651965
#define SESSION_SET_USER_HANDLER_OO_MANDATORY(struct_name, method_name) \
1966-
if (!Z_ISUNDEF(PS(mod_user_names).name.struct_name)) { \
1967-
zval_ptr_dtor(&PS(mod_user_names).name.struct_name); \
1966+
if (!Z_ISUNDEF(PS(mod_user_names).struct_name)) { \
1967+
zval_ptr_dtor(&PS(mod_user_names).struct_name); \
19681968
} \
1969-
array_init_size(&PS(mod_user_names).name.struct_name, 2); \
1969+
array_init_size(&PS(mod_user_names).struct_name, 2); \
19701970
Z_ADDREF_P(obj); \
1971-
add_next_index_zval(&PS(mod_user_names).name.struct_name, obj); \
1972-
add_next_index_str(&PS(mod_user_names).name.struct_name, zend_string_init(method_name, strlen(method_name), false));
1971+
add_next_index_zval(&PS(mod_user_names).struct_name, obj); \
1972+
add_next_index_str(&PS(mod_user_names).struct_name, zend_string_init(method_name, strlen(method_name), false));
19731973

19741974
#define SESSION_SET_USER_HANDLER_PROCEDURAL(struct_name, fci) \
1975-
if (!Z_ISUNDEF(PS(mod_user_names).name.struct_name)) { \
1976-
zval_ptr_dtor(&PS(mod_user_names).name.struct_name); \
1975+
if (!Z_ISUNDEF(PS(mod_user_names).struct_name)) { \
1976+
zval_ptr_dtor(&PS(mod_user_names).struct_name); \
19771977
} \
1978-
ZVAL_COPY(&PS(mod_user_names).name.struct_name, &fci.function_name);
1978+
ZVAL_COPY(&PS(mod_user_names).struct_name, &fci.function_name);
19791979

19801980
#define SESSION_SET_USER_HANDLER_PROCEDURAL_OPTIONAL(struct_name, fci) \
19811981
if (ZEND_FCI_INITIALIZED(fci)) { \
@@ -2294,7 +2294,7 @@ PHP_FUNCTION(session_regenerate_id)
22942294
RETURN_THROWS();
22952295
}
22962296
if (PS(use_strict_mode)) {
2297-
if ((!PS(mod_user_implemented) && PS(mod)->s_validate_sid) || !Z_ISUNDEF(PS(mod_user_names).name.ps_validate_sid)) {
2297+
if ((!PS(mod_user_implemented) && PS(mod)->s_validate_sid) || !Z_ISUNDEF(PS(mod_user_names).ps_validate_sid)) {
22982298
int limit = 3;
22992299
/* Try to generate non-existing ID */
23002300
while (limit-- && PS(mod)->s_validate_sid(&PS(mod_data), PS(id)) == SUCCESS) {
@@ -2360,7 +2360,7 @@ PHP_FUNCTION(session_create_id)
23602360
int limit = 3;
23612361
while (limit--) {
23622362
new_id = PS(mod)->s_create_sid(&PS(mod_data));
2363-
if (!PS(mod)->s_validate_sid || (PS(mod_user_implemented) && Z_ISUNDEF(PS(mod_user_names).name.ps_validate_sid))) {
2363+
if (!PS(mod)->s_validate_sid || (PS(mod_user_implemented) && Z_ISUNDEF(PS(mod_user_names).ps_validate_sid))) {
23642364
break;
23652365
} else {
23662366
/* Detect collision and retry */
@@ -2776,9 +2776,9 @@ static PHP_RINIT_FUNCTION(session) /* {{{ */
27762776
/* }}} */
27772777

27782778
#define SESSION_FREE_USER_HANDLER(struct_name) \
2779-
if (!Z_ISUNDEF(PS(mod_user_names).name.struct_name)) { \
2780-
zval_ptr_dtor(&PS(mod_user_names).name.struct_name); \
2781-
ZVAL_UNDEF(&PS(mod_user_names).name.struct_name); \
2779+
if (!Z_ISUNDEF(PS(mod_user_names).struct_name)) { \
2780+
zval_ptr_dtor(&PS(mod_user_names).struct_name); \
2781+
ZVAL_UNDEF(&PS(mod_user_names).struct_name); \
27822782
}
27832783

27842784

@@ -2827,15 +2827,15 @@ static PHP_GINIT_FUNCTION(ps) /* {{{ */
28272827
ps_globals->session_vars = NULL;
28282828
ps_globals->set_handler = 0;
28292829
/* Unset user defined handlers */
2830-
ZVAL_UNDEF(&ps_globals->mod_user_names.name.ps_open);
2831-
ZVAL_UNDEF(&ps_globals->mod_user_names.name.ps_close);
2832-
ZVAL_UNDEF(&ps_globals->mod_user_names.name.ps_read);
2833-
ZVAL_UNDEF(&ps_globals->mod_user_names.name.ps_write);
2834-
ZVAL_UNDEF(&ps_globals->mod_user_names.name.ps_destroy);
2835-
ZVAL_UNDEF(&ps_globals->mod_user_names.name.ps_gc);
2836-
ZVAL_UNDEF(&ps_globals->mod_user_names.name.ps_create_sid);
2837-
ZVAL_UNDEF(&ps_globals->mod_user_names.name.ps_validate_sid);
2838-
ZVAL_UNDEF(&ps_globals->mod_user_names.name.ps_update_timestamp);
2830+
ZVAL_UNDEF(&ps_globals->mod_user_names.ps_open);
2831+
ZVAL_UNDEF(&ps_globals->mod_user_names.ps_close);
2832+
ZVAL_UNDEF(&ps_globals->mod_user_names.ps_read);
2833+
ZVAL_UNDEF(&ps_globals->mod_user_names.ps_write);
2834+
ZVAL_UNDEF(&ps_globals->mod_user_names.ps_destroy);
2835+
ZVAL_UNDEF(&ps_globals->mod_user_names.ps_gc);
2836+
ZVAL_UNDEF(&ps_globals->mod_user_names.ps_create_sid);
2837+
ZVAL_UNDEF(&ps_globals->mod_user_names.ps_validate_sid);
2838+
ZVAL_UNDEF(&ps_globals->mod_user_names.ps_update_timestamp);
28392839
ZVAL_UNDEF(&ps_globals->http_session_vars);
28402840
}
28412841
/* }}} */

0 commit comments

Comments
 (0)