if (!resolved_path) {
if (SG(request_info).path_translated != filename) {
-//??? STR_FREE(filename);
- if (filename) efree(filename);
+ if (filename) {
+ efree(filename);
+ }
}
/* we have to free SG(request_info).path_translated here because
* php_destroy_request_info assumes that it will get
* freed when the include_names hash is emptied, but
* we're not adding it in this case */
-//??? STR_FREE(SG(request_info).path_translated);
- if (SG(request_info).path_translated) efree(SG(request_info).path_translated);
- SG(request_info).path_translated = NULL;
+ if (SG(request_info).path_translated) {
+ efree(SG(request_info).path_translated);
+ SG(request_info).path_translated = NULL;
+ }
return FAILURE;
}
efree(resolved_path);
if (zend_stream_open(filename, file_handle TSRMLS_CC) == FAILURE) {
PG(display_errors) = orig_display_errors;
if (SG(request_info).path_translated != filename) {
-//??? STR_FREE(filename);
- if (filename) efree(filename);
+ if (filename) {
+ efree(filename);
+ }
+ }
+ if (SG(request_info).path_translated) {
+ efree(SG(request_info).path_translated);
+ SG(request_info).path_translated = NULL;
}
-//??? STR_FREE(SG(request_info).path_translated); /* for same reason as above */
- if (SG(request_info).path_translated) efree(SG(request_info).path_translated);
- SG(request_info).path_translated = NULL;
return FAILURE;
}
PG(display_errors) = orig_display_errors;
if (SG(request_info).path_translated != filename) {
-//??? STR_FREE(SG(request_info).path_translated); /* for same reason as above */
- if (SG(request_info).path_translated) efree(SG(request_info).path_translated);
+ if (SG(request_info).path_translated) {
+ efree(SG(request_info).path_translated);
+ }
SG(request_info).path_translated = filename;
}
static inline int php_output_lock_error(int op TSRMLS_DC);
static inline void php_output_op(int op, const char *str, size_t len TSRMLS_DC);
-static inline php_output_handler *php_output_handler_init(const char *name, size_t name_len, size_t chunk_size, int flags TSRMLS_DC);
+static inline php_output_handler *php_output_handler_init(zend_string *name, size_t chunk_size, int flags TSRMLS_DC);
static inline php_output_handler_status_t php_output_handler_op(php_output_handler *handler, php_output_context *context);
static inline int php_output_handler_append(php_output_handler *handler, const php_output_buffer *buf TSRMLS_DC);
static inline zval *php_output_handler_status(php_output_handler *handler, zval *entry);
default:
user = ecalloc(1, sizeof(php_output_handler_user_func_t));
if (SUCCESS == zend_fcall_info_init(output_handler, 0, &user->fci, &user->fcc, &handler_name, &error TSRMLS_CC)) {
- handler = php_output_handler_init(handler_name->val, handler_name->len, chunk_size, (flags & ~0xf) | PHP_OUTPUT_HANDLER_USER TSRMLS_CC);
+ handler = php_output_handler_init(handler_name, chunk_size, (flags & ~0xf) | PHP_OUTPUT_HANDLER_USER TSRMLS_CC);
ZVAL_COPY(&user->zoh, output_handler);
handler->func.user = user;
} else {
PHPAPI php_output_handler *php_output_handler_create_internal(const char *name, size_t name_len, php_output_handler_context_func_t output_handler, size_t chunk_size, int flags TSRMLS_DC)
{
php_output_handler *handler;
+ zend_string *str = STR_INIT(name, name_len, 1);
- handler = php_output_handler_init(name, name_len, chunk_size, (flags & ~0xf) | PHP_OUTPUT_HANDLER_INTERNAL TSRMLS_CC);
+ handler = php_output_handler_init(str, chunk_size, (flags & ~0xf) | PHP_OUTPUT_HANDLER_INTERNAL TSRMLS_CC);
handler->func.internal = output_handler;
+ STR_RELEASE(str);
return handler;
}
if (php_output_lock_error(PHP_OUTPUT_HANDLER_START TSRMLS_CC) || !handler) {
return FAILURE;
}
- if (NULL != (conflict = zend_hash_str_find_ptr(&php_output_handler_conflicts, handler->name, handler->name_len))) {
- if (SUCCESS != conflict(handler->name, handler->name_len TSRMLS_CC)) {
+ if (NULL != (conflict = zend_hash_find_ptr(&php_output_handler_conflicts, handler->name))) {
+ if (SUCCESS != conflict(handler->name->val, handler->name->len TSRMLS_CC)) {
return FAILURE;
}
}
- if (NULL != (rconflicts = zend_hash_str_find_ptr(&php_output_handler_reverse_conflicts, handler->name, handler->name_len))) {
+ if (NULL != (rconflicts = zend_hash_find_ptr(&php_output_handler_reverse_conflicts, handler->name))) {
for (zend_hash_internal_pointer_reset_ex(rconflicts, &pos);
(conflict = zend_hash_get_current_data_ptr_ex(rconflicts, &pos)) != NULL;
zend_hash_move_forward_ex(rconflicts, &pos)
) {
- if (SUCCESS != conflict(handler->name, handler->name_len TSRMLS_CC)) {
+ if (SUCCESS != conflict(handler->name->val, handler->name->len TSRMLS_CC)) {
return FAILURE;
}
}
handlers = (php_output_handler **) zend_stack_base(&OG(handlers));
for (i = 0; i < count; ++i) {
- if (name_len == handlers[i]->name_len && !memcmp(handlers[i]->name, name, name_len)) {
+ if (name_len == handlers[i]->name->len && !memcmp(handlers[i]->name->val, name, name_len)) {
return 1;
}
}
* Destroy an output handler */
PHPAPI void php_output_handler_dtor(php_output_handler *handler TSRMLS_DC)
{
-//??? STR_FREE(handler->name);
- if (handler->name) efree(handler->name);
-//??? STR_FREE(handler->buffer.data);
- if (handler->buffer.data) efree(handler->buffer.data);
+ if (handler->name) {
+ STR_RELEASE(handler->name);
+ }
+ if (handler->buffer.data) {
+ efree(handler->buffer.data);
+ }
if (handler->flags & PHP_OUTPUT_HANDLER_USER) {
zval_ptr_dtor(&handler->func.user->zoh);
efree(handler->func.user);
/* {{{ static php_output_handler *php_output_handler_init(zval *name, size_t chunk_size, int flags TSRMLS_DC)
* Allocates and initializes a php_output_handler structure */
-static inline php_output_handler *php_output_handler_init(const char *name, size_t name_len, size_t chunk_size, int flags TSRMLS_DC)
+static inline php_output_handler *php_output_handler_init(zend_string *name, size_t chunk_size, int flags TSRMLS_DC)
{
php_output_handler *handler;
handler = ecalloc(1, sizeof(php_output_handler));
- handler->name = estrndup(name, name_len);
- handler->name_len = name_len;
+ handler->name = STR_COPY(name);
handler->size = chunk_size;
handler->flags = flags;
handler->buffer.size = PHP_OUTPUT_HANDLER_INITBUF_SIZE(chunk_size);
php_output_handler *handler = *(php_output_handler **) h;
zval *array = (zval *) z;
- add_next_index_stringl(array, handler->name, handler->name_len);
+ add_next_index_str(array, STR_COPY(handler->name));
return 0;
}
/* }}} */
ZEND_ASSERT(entry != NULL);
array_init(entry);
- add_assoc_stringl(entry, "name", handler->name, handler->name_len);
+ add_assoc_str(entry, "name", STR_COPY(handler->name));
add_assoc_long(entry, "type", (long) (handler->flags & 0xf));
add_assoc_long(entry, "flags", (long) handler->flags);
add_assoc_long(entry, "level", (long) handler->level);
return 0;
} else if (!(flags & PHP_OUTPUT_POP_FORCE) && !(orphan->flags & PHP_OUTPUT_HANDLER_REMOVABLE)) {
if (!(flags & PHP_OUTPUT_POP_SILENT)) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to %s buffer of %s (%d)", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send", orphan->name, orphan->level);
+ php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to %s buffer of %s (%d)", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send", orphan->name->val, orphan->level);
}
return 0;
} else {
}
if (SUCCESS != php_output_flush(TSRMLS_C)) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to flush buffer of %s (%d)", OG(active)->name, OG(active)->level);
+ php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to flush buffer of %s (%d)", OG(active)->name->val, OG(active)->level);
RETURN_FALSE;
}
RETURN_TRUE;
}
if (SUCCESS != php_output_clean(TSRMLS_C)) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer of %s (%d)", OG(active)->name, OG(active)->level);
+ php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer of %s (%d)", OG(active)->name->val, OG(active)->level);
RETURN_FALSE;
}
RETURN_TRUE;
}
if (SUCCESS != php_output_end(TSRMLS_C)) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer of %s (%d)", OG(active)->name, OG(active)->level);
+ php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer of %s (%d)", OG(active)->name->val, OG(active)->level);
}
}
/* }}} */
}
if (SUCCESS != php_output_discard(TSRMLS_C)) {
- php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer of %s (%d)", OG(active)->name, OG(active)->level);
+ php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer of %s (%d)", OG(active)->name->val, OG(active)->level);
}
}
/* }}} */