@@ -116,10 +116,7 @@ PHPAPI int php_output_activate(TSRMLS_D)
116
116
memset (& output_globals , 0 , sizeof (zend_output_globals ));
117
117
#endif
118
118
119
- OG (handlers ) = emalloc (sizeof (zend_stack ));
120
- if (SUCCESS != zend_stack_init (OG (handlers ))) {
121
- return FAILURE ;
122
- }
119
+ zend_stack_init (& OG (handlers ));
123
120
124
121
return SUCCESS ;
125
122
}
@@ -135,14 +132,12 @@ PHPAPI void php_output_deactivate(TSRMLS_D)
135
132
OG (running ) = NULL ;
136
133
137
134
/* release all output handlers */
138
- if (OG (handlers )) {
139
- while (SUCCESS == zend_stack_top (OG (handlers ), (void * ) & handler )) {
135
+ if (OG (handlers ). elements ) {
136
+ while (SUCCESS == zend_stack_top (& OG (handlers ), (void * ) & handler )) {
140
137
php_output_handler_free (handler TSRMLS_CC );
141
- zend_stack_del_top (OG (handlers ));
138
+ zend_stack_del_top (& OG (handlers ));
142
139
}
143
- zend_stack_destroy (OG (handlers ));
144
- efree (OG (handlers ));
145
- OG (handlers ) = NULL ;
140
+ zend_stack_destroy (& OG (handlers ));
146
141
}
147
142
}
148
143
/* }}} */
@@ -218,9 +213,9 @@ PHPAPI int php_output_flush(TSRMLS_D)
218
213
php_output_context_init (& context , PHP_OUTPUT_HANDLER_FLUSH TSRMLS_CC );
219
214
php_output_handler_op (OG (active ), & context );
220
215
if (context .out .data && context .out .used ) {
221
- zend_stack_del_top (OG (handlers ));
216
+ zend_stack_del_top (& OG (handlers ));
222
217
php_output_write (context .out .data , context .out .used TSRMLS_CC );
223
- zend_stack_push (OG (handlers ), & OG (active ), sizeof (php_output_handler * ));
218
+ zend_stack_push (& OG (handlers ), & OG (active ), sizeof (php_output_handler * ));
224
219
}
225
220
php_output_context_dtor (& context );
226
221
return SUCCESS ;
@@ -264,7 +259,7 @@ PHPAPI void php_output_clean_all(TSRMLS_D)
264
259
265
260
if (OG (active )) {
266
261
php_output_context_init (& context , PHP_OUTPUT_HANDLER_CLEAN TSRMLS_CC );
267
- zend_stack_apply_with_argument (OG (handlers ), ZEND_STACK_APPLY_TOPDOWN , php_output_stack_apply_clean , & context );
262
+ zend_stack_apply_with_argument (& OG (handlers ), ZEND_STACK_APPLY_TOPDOWN , php_output_stack_apply_clean , & context );
268
263
}
269
264
}
270
265
@@ -312,7 +307,7 @@ PHPAPI void php_output_discard_all(TSRMLS_D)
312
307
Get output buffering level, ie. how many output handlers the stack contains */
313
308
PHPAPI int php_output_get_level (TSRMLS_D )
314
309
{
315
- return OG (active ) ? zend_stack_count (OG (handlers )) : 0 ;
310
+ return OG (active ) ? zend_stack_count (& OG (handlers )) : 0 ;
316
311
}
317
312
/* }}} */
318
313
@@ -500,7 +495,7 @@ PHPAPI int php_output_handler_start(php_output_handler *handler TSRMLS_DC)
500
495
}
501
496
}
502
497
/* zend_stack_push never returns SUCCESS but FAILURE or stack level */
503
- if (FAILURE == (handler -> level = zend_stack_push (OG (handlers ), & handler , sizeof (php_output_handler * )))) {
498
+ if (FAILURE == (handler -> level = zend_stack_push (& OG (handlers ), & handler , sizeof (php_output_handler * )))) {
504
499
return FAILURE ;
505
500
}
506
501
OG (active ) = handler ;
@@ -516,7 +511,7 @@ PHPAPI int php_output_handler_started(const char *name, size_t name_len TSRMLS_D
516
511
int i , count = php_output_get_level (TSRMLS_C );
517
512
518
513
if (count ) {
519
- handlers = * (php_output_handler * * * ) zend_stack_base (OG (handlers ));
514
+ handlers = * (php_output_handler * * * ) zend_stack_base (& OG (handlers ));
520
515
521
516
for (i = 0 ; i < count ; ++ i ) {
522
517
if (name_len == handlers [i ]-> name_len && !memcmp (handlers [i ]-> name , name , name_len )) {
@@ -977,13 +972,13 @@ static inline void php_output_op(int op, const char *str, size_t len TSRMLS_DC)
977
972
* - apply op to the one active handler; note that OG(active) might be popped off the stack on a flush
978
973
* - or apply op to the handler stack
979
974
*/
980
- if (OG (active ) && (obh_cnt = zend_stack_count (OG (handlers )))) {
975
+ if (OG (active ) && (obh_cnt = zend_stack_count (& OG (handlers )))) {
981
976
context .in .data = (char * ) str ;
982
977
context .in .used = len ;
983
978
984
979
if (obh_cnt > 1 ) {
985
- zend_stack_apply_with_argument (OG (handlers ), ZEND_STACK_APPLY_TOPDOWN , php_output_stack_apply_op , & context );
986
- } else if ((SUCCESS == zend_stack_top (OG (handlers ), (void * ) & active )) && (!((* active )-> flags & PHP_OUTPUT_HANDLER_DISABLED ))) {
980
+ zend_stack_apply_with_argument (& OG (handlers ), ZEND_STACK_APPLY_TOPDOWN , php_output_stack_apply_op , & context );
981
+ } else if ((SUCCESS == zend_stack_top (& OG (handlers ), (void * ) & active )) && (!((* active )-> flags & PHP_OUTPUT_HANDLER_DISABLED ))) {
987
982
php_output_handler_op (* active , & context );
988
983
} else {
989
984
php_output_context_pass (& context );
@@ -1161,8 +1156,8 @@ static inline int php_output_stack_pop(int flags TSRMLS_DC)
1161
1156
}
1162
1157
1163
1158
/* pop it off the stack */
1164
- zend_stack_del_top (OG (handlers ));
1165
- if (SUCCESS == zend_stack_top (OG (handlers ), (void * ) & current )) {
1159
+ zend_stack_del_top (& OG (handlers ));
1160
+ if (SUCCESS == zend_stack_top (& OG (handlers ), (void * ) & current )) {
1166
1161
OG (active ) = * current ;
1167
1162
} else {
1168
1163
OG (active ) = NULL ;
@@ -1411,7 +1406,7 @@ PHP_FUNCTION(ob_list_handlers)
1411
1406
return ;
1412
1407
}
1413
1408
1414
- zend_stack_apply_with_argument (OG (handlers ), ZEND_STACK_APPLY_BOTTOMUP , php_output_stack_apply_list , return_value );
1409
+ zend_stack_apply_with_argument (& OG (handlers ), ZEND_STACK_APPLY_BOTTOMUP , php_output_stack_apply_list , return_value );
1415
1410
}
1416
1411
/* }}} */
1417
1412
@@ -1430,7 +1425,7 @@ PHP_FUNCTION(ob_get_status)
1430
1425
1431
1426
array_init (return_value );
1432
1427
if (full_status ) {
1433
- zend_stack_apply_with_argument (OG (handlers ), ZEND_STACK_APPLY_BOTTOMUP , php_output_stack_apply_status , return_value );
1428
+ zend_stack_apply_with_argument (& OG (handlers ), ZEND_STACK_APPLY_BOTTOMUP , php_output_stack_apply_status , return_value );
1434
1429
} else {
1435
1430
php_output_handler_status (OG (active ), return_value );
1436
1431
}
0 commit comments