zval z_key;
ZVAL_LONG(&tmp, n);
- ZVAL_STRINGL(&z_key, key, key_len-1);
+ ZVAL_STRINGL(&z_key, key, key_len);
Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, 0 TSRMLS_CC);
zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
zval_ptr_dtor(&z_key);
zval z_key;
ZVAL_BOOL(&tmp, b);
- ZVAL_STRINGL(&z_key, key, key_len-1);
+ ZVAL_STRINGL(&z_key, key, key_len);
Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, 0 TSRMLS_CC);
zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
zval_ptr_dtor(&z_key);
zval z_key;
ZVAL_NULL(&tmp);
- ZVAL_STRINGL(&z_key, key, key_len-1);
+ ZVAL_STRINGL(&z_key, key, key_len);
Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, 0 TSRMLS_CC);
zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
zval_ptr_dtor(&z_key);
zval z_key;
ZVAL_RES(&tmp, r);
- ZVAL_STRINGL(&z_key, key, key_len-1);
+ ZVAL_STRINGL(&z_key, key, key_len);
Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, 0 TSRMLS_CC);
zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
zval_ptr_dtor(&z_key);
zval z_key;
ZVAL_DOUBLE(&tmp, d);
- ZVAL_STRINGL(&z_key, key, key_len-1);
+ ZVAL_STRINGL(&z_key, key, key_len);
Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, 0 TSRMLS_CC);
zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
zval_ptr_dtor(&z_key);
//??? ZVAL_STRING(tmp, str, duplicate);
ZVAL_STRING(&tmp, str);
- ZVAL_STRINGL(&z_key, key, key_len-1);
+ ZVAL_STRINGL(&z_key, key, key_len);
Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, 0 TSRMLS_CC);
zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
zval_ptr_dtor(&z_key);
//??? ZVAL_STRINGL(tmp, str, length, duplicate);
ZVAL_STRINGL(&tmp, str, length);
- ZVAL_STRINGL(&z_key, key, key_len-1);
+ ZVAL_STRINGL(&z_key, key, key_len);
Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, &tmp, 0 TSRMLS_CC);
zval_ptr_dtor(&tmp); /* write_property will add 1 to refcount */
zval_ptr_dtor(&z_key);
{
zval z_key;
- ZVAL_STRINGL(&z_key, key, key_len-1);
+ ZVAL_STRINGL(&z_key, key, key_len);
Z_OBJ_HANDLER_P(arg, write_property)(arg, &z_key, value, 0 TSRMLS_CC);
zval_ptr_dtor(&z_key);
return SUCCESS;
{
php_stream_bucket *bucket;
size_t consumed = 0;
- php_strip_tags_filter *inst = (php_strip_tags_filter *) thisfilter->abstract;
+ php_strip_tags_filter *inst = (php_strip_tags_filter *) Z_PTR(thisfilter->abstract);
while (buckets_in->head) {
bucket = php_stream_bucket_make_writeable(buckets_in->head TSRMLS_CC);
static void strfilter_strip_tags_dtor(php_stream_filter *thisfilter TSRMLS_DC)
{
- assert(thisfilter->abstract != NULL);
+ assert(Z_PTR(thisfilter->abstract) != NULL);
- php_strip_tags_filter_dtor((php_strip_tags_filter *)thisfilter->abstract);
+ php_strip_tags_filter_dtor((php_strip_tags_filter *)Z_PTR(thisfilter->abstract));
- pefree(thisfilter->abstract, ((php_strip_tags_filter *)thisfilter->abstract)->persistent);
+ pefree(Z_PTR(thisfilter->abstract), ((php_strip_tags_filter *)Z_PTR(thisfilter->abstract))->persistent);
}
static php_stream_filter_ops strfilter_strip_tags_ops = {
{
php_stream_bucket *bucket = NULL;
size_t consumed = 0;
- php_convert_filter *inst = (php_convert_filter *)thisfilter->abstract;
+ php_convert_filter *inst = (php_convert_filter *)Z_PTR(thisfilter->abstract);
while (buckets_in->head != NULL) {
bucket = buckets_in->head;
static void strfilter_convert_dtor(php_stream_filter *thisfilter TSRMLS_DC)
{
- assert(thisfilter->abstract != NULL);
+ assert(Z_PTR(thisfilter->abstract) != NULL);
- php_convert_filter_dtor((php_convert_filter *)thisfilter->abstract);
- pefree(thisfilter->abstract, ((php_convert_filter *)thisfilter->abstract)->persistent);
+ php_convert_filter_dtor((php_convert_filter *)Z_PTR(thisfilter->abstract));
+ pefree(Z_PTR(thisfilter->abstract), ((php_convert_filter *)Z_PTR(thisfilter->abstract))->persistent);
}
static php_stream_filter_ops strfilter_convert_ops = {
int flags
TSRMLS_DC)
{
- php_consumed_filter_data *data = (php_consumed_filter_data *)(thisfilter->abstract);
+ php_consumed_filter_data *data = (php_consumed_filter_data *)Z_PTR(thisfilter->abstract);
php_stream_bucket *bucket;
size_t consumed = 0;
static void consumed_filter_dtor(php_stream_filter *thisfilter TSRMLS_DC)
{
- if (thisfilter && thisfilter->abstract) {
- php_consumed_filter_data *data = (php_consumed_filter_data*)thisfilter->abstract;
+ if (thisfilter && Z_PTR(thisfilter->abstract)) {
+ php_consumed_filter_data *data = (php_consumed_filter_data*)Z_PTR(thisfilter->abstract);
pefree(data, data->persistent);
}
}
{
php_stream_bucket *bucket;
size_t consumed = 0;
- php_chunked_filter_data *data = (php_chunked_filter_data *) thisfilter->abstract;
+ php_chunked_filter_data *data = (php_chunked_filter_data *) Z_PTR(thisfilter->abstract);
while (buckets_in->head) {
bucket = php_stream_bucket_make_writeable(buckets_in->head TSRMLS_CC);
static void php_chunked_dtor(php_stream_filter *thisfilter TSRMLS_DC)
{
- if (thisfilter && thisfilter->abstract) {
- php_chunked_filter_data *data = (php_chunked_filter_data *) thisfilter->abstract;
+ if (thisfilter && Z_PTR(thisfilter->abstract)) {
+ php_chunked_filter_data *data = (php_chunked_filter_data *) Z_PTR(thisfilter->abstract);
pefree(data, data->persistent);
}
}
if (filter) {
filter->res = ZEND_REGISTER_RESOURCE(NULL, filter, php_file_le_stream_filter());
+ filter->res->gc.refcount++;
RETURN_RES(filter->res);
} else {
RETURN_FALSE;
static void userfilter_dtor(php_stream_filter *thisfilter TSRMLS_DC)
{
- zval *obj = (zval*)thisfilter->abstract;
+ zval *obj = &thisfilter->abstract;
zval func_name;
zval retval;
return;
}
-//??? ZVAL_STRINGL(&func_name, "onclose", sizeof("onclose")-1, 0);
ZVAL_STRINGL(&func_name, "onclose", sizeof("onclose")-1);
call_user_function_ex(NULL,
0, NULL TSRMLS_CC);
zval_ptr_dtor(&retval);
+ zval_ptr_dtor(&func_name);
/* kill the object */
zval_ptr_dtor(obj);
TSRMLS_DC)
{
int ret = PSFS_ERR_FATAL;
- zval *obj = (zval*)thisfilter->abstract;
+ zval *obj = &thisfilter->abstract;
zval func_name;
zval retval;
zval args[4];
zval_ptr_dtor(&tmp);
}
-//??? ZVAL_STRINGL(&func_name, "filter", sizeof("filter")-1, 0);
ZVAL_STRINGL(&func_name, "filter", sizeof("filter")-1);
/* Setup calling arguments */
4, args,
0, NULL TSRMLS_CC);
+ zval_ptr_dtor(&func_name);
+
if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
convert_to_long(&retval);
ret = Z_LVAL(retval);
/* filter resources are cleaned up by the stream destructor,
* keeping a reference to the stream resource here would prevent it
* from being destroyed properly */
-//??? ZVAL_STRINGL(&zpropname, "stream", sizeof("stream")-1, 0);
ZVAL_STRINGL(&zpropname, "stream", sizeof("stream")-1);
Z_OBJ_HANDLER_P(obj, unset_property)(obj, &zpropname, 0 TSRMLS_CC);
+ zval_ptr_dtor(&zpropname);
zval_ptr_dtor(&args[3]);
zval_ptr_dtor(&args[2]);
}
/* invoke the constructor */
-//??? ZVAL_STRINGL(&func_name, "oncreate", sizeof("oncreate")-1, 0);
ZVAL_STRINGL(&func_name, "oncreate", sizeof("oncreate")-1);
call_user_function_ex(NULL,
zval_ptr_dtor(&retval);
/* Kill the filter (safely) */
- filter->abstract = NULL;
+ ZVAL_UNDEF(&filter->abstract);
php_stream_filter_free(filter TSRMLS_CC);
/* Kill the object */
}
zval_ptr_dtor(&retval);
}
+ zval_ptr_dtor(&func_name);
/* set the filter property, this will be used during cleanup */
ZEND_REGISTER_RESOURCE(&zfilter, filter, le_userfilters);
-//???
- filter->abstract = &obj;
+ ZVAL_COPY_VALUE(&filter->abstract, &obj);
add_property_zval(&obj, "filter", &zfilter);
/* add_property_zval increments the refcount which is unwanted here */
zval_ptr_dtor(&zfilter);
user_filter_factory_create
};
-static void filter_item_dtor(struct php_user_filter_data *fdat)
+static void filter_item_dtor(zval *zv)
{
+ struct php_user_filter_data *fdat = Z_PTR_P(zv);
+ efree(fdat);
}
/* {{{ proto object stream_bucket_make_writeable(resource brigade)
(key_flags = zend_hash_get_current_key_ex(filters_hash, &filter_name, &num_key, 0, NULL)) != HASH_KEY_NON_EXISTENT;
zend_hash_move_forward(filters_hash))
if (key_flags == HASH_KEY_IS_STRING) {
-//???
- add_next_index_stringl(return_value, filter_name->val, filter_name->len, 1);
+ add_next_index_str(return_value, STR_COPY(filter_name));
}
}
/* It's okay to return an empty array if no filters are registered */
memset(filter, 0, sizeof(php_stream_filter));
filter->fops = fops;
- filter->abstract = abstract;
+ Z_PTR(filter->abstract) = abstract;
filter->is_persistent = persistent;
return filter;
struct _php_stream_filter {
php_stream_filter_ops *fops;
- void *abstract; /* for use by filter implementation */
+ zval abstract; /* for use by filter implementation */
php_stream_filter *next;
php_stream_filter *prev;
int is_persistent;