Skip to content

Commit 236349f

Browse files
committed
User Filters don't need to register a resource list for streams.
That functionality is already exported by the streams API.
1 parent 99db196 commit 236349f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

ext/standard/user_filters.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#define PHP_STREAM_BRIGADE_RES_NAME "userfilter.bucket brigade"
2929
#define PHP_STREAM_BUCKET_RES_NAME "userfilter.bucket"
3030
#define PHP_STREAM_FILTER_RES_NAME "userfilter.filter"
31-
#define PHP_STREAM_RES_NAME "userfilter.stream"
3231

3332
struct php_user_filter_data {
3433
zend_class_entry *ce;
@@ -40,7 +39,6 @@ struct php_user_filter_data {
4039
static int le_userfilters;
4140
static int le_bucket_brigade;
4241
static int le_bucket;
43-
static int le_stream;
4442

4543
#define GET_FILTER_FROM_OBJ() { \
4644
zval **tmp; \
@@ -82,9 +80,10 @@ PHP_MINIT_FUNCTION(user_filters)
8280
return FAILURE;
8381
}
8482

83+
/* Filters will dispose of their brigades */
8584
le_bucket_brigade = zend_register_list_destructors_ex(NULL, NULL, PHP_STREAM_BRIGADE_RES_NAME, module_number);
85+
/* Brigades will dispose of their buckets */
8686
le_bucket = zend_register_list_destructors_ex(NULL, NULL, PHP_STREAM_BUCKET_RES_NAME, module_number);
87-
le_stream = zend_register_list_destructors_ex(NULL, NULL, PHP_STREAM_RES_NAME, module_number);
8887

8988
if (le_bucket_brigade == FAILURE) {
9089
return FAILURE;
@@ -149,7 +148,7 @@ php_stream_filter_status_t userfilter_filter(
149148
if (FAILURE == zend_hash_find(Z_OBJPROP_P(obj), "stream", sizeof("stream"), (void**)&zstream)) {
150149
/* Give the userfilter class a hook back to the stream */
151150
ALLOC_INIT_ZVAL(zstream);
152-
ZEND_REGISTER_RESOURCE(zstream, stream, le_stream);
151+
php_stream_to_zval(stream, zstream);
153152
add_property_zval(obj, "stream", zstream);
154153
/* add_property_zval increments the refcount which is unwanted here */
155154
zval_ptr_dtor(&zstream);
@@ -402,7 +401,7 @@ PHP_FUNCTION(stream_bucket_new)
402401
RETURN_FALSE;
403402
}
404403

405-
ZEND_FETCH_RESOURCE(stream, php_stream *, &zstream, -1, PHP_STREAM_RES_NAME, le_stream);
404+
php_stream_from_zval(stream, &zstream);
406405

407406
if (!(pbuffer = pemalloc(buffer_len, php_stream_is_persistent(stream)))) {
408407
RETURN_FALSE;

0 commit comments

Comments
 (0)