X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=http_deflatestream_object.c;h=9d99bc9aa239c9d371d520e70cb6b518d0116f15;hp=4b9e582a64003496f4b262c229eeb7c20512f364;hb=82e8bfff78f52b0989fb865131461fe61156f507;hpb=efd602160cd419f39504f5f58df0d2890a607206 diff --git a/http_deflatestream_object.c b/http_deflatestream_object.c index 4b9e582..9d99bc9 100644 --- a/http_deflatestream_object.c +++ b/http_deflatestream_object.c @@ -71,6 +71,9 @@ PHP_MINIT_FUNCTION(http_deflatestream_object) DCL_CONST(long, "STRATEGY_HUFF", HTTP_DEFLATE_STRATEGY_HUFF); DCL_CONST(long, "STRATEGY_RLE", HTTP_DEFLATE_STRATEGY_RLE); DCL_CONST(long, "STRATEGY_FIXED", HTTP_DEFLATE_STRATEGY_FIXED); + DCL_CONST(long, "FLUSH_NONE", HTTP_ENCODING_STREAM_FLUSH_NONE); + DCL_CONST(long, "FLUSH_SYNC", HTTP_ENCODING_STREAM_FLUSH_SYNC); + DCL_CONST(long, "FLUSH_FULL", HTTP_ENCODING_STREAM_FLUSH_FULL); #endif return SUCCESS; @@ -98,7 +101,8 @@ zend_object_value _http_deflatestream_object_new_ex(zend_class_entry *ce, http_e } ALLOC_HASHTABLE(OBJ_PROP(o)); - zend_hash_init(OBJ_PROP(o), 0, NULL, ZVAL_PTR_DTOR, 0); + zend_hash_init(OBJ_PROP(o), zend_hash_num_elements(&ce->default_properties), NULL, ZVAL_PTR_DTOR, 0); + zend_hash_copy(OBJ_PROP(o), &ce->default_properties, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); ov.handle = putObject(http_deflatestream_object, o); ov.handlers = &http_deflatestream_object_handlers; @@ -109,28 +113,29 @@ zend_object_value _http_deflatestream_object_new_ex(zend_class_entry *ce, http_e zend_object_value _http_deflatestream_object_clone_obj(zval *this_ptr TSRMLS_DC) { http_encoding_stream *s; - getObject(http_deflatestream_object, obj); + zend_object_value new_ov; + http_deflatestream_object *new_obj = NULL; + getObject(http_deflatestream_object, old_obj); s = ecalloc(1, sizeof(http_encoding_stream)); - s->flags = obj->stream->flags; - deflateCopy(&s->stream, &obj->stream->stream); + s->flags = old_obj->stream->flags; + deflateCopy(&s->stream, &old_obj->stream->stream); s->stream.opaque = phpstr_dup(s->stream.opaque); - return http_deflatestream_object_new_ex(Z_OBJCE_P(this_ptr), s, NULL); + new_ov = http_deflatestream_object_new_ex(old_obj->zo.ce, s, &new_obj); + zend_objects_clone_members(&new_obj->zo, new_ov, &old_obj->zo, Z_OBJ_HANDLE_P(this_ptr) TSRMLS_CC); + + return new_ov; } void _http_deflatestream_object_free(zend_object *object TSRMLS_DC) { http_deflatestream_object *o = (http_deflatestream_object *) object; - if (OBJ_PROP(o)) { - zend_hash_destroy(OBJ_PROP(o)); - FREE_HASHTABLE(OBJ_PROP(o)); - } if (o->stream) { http_encoding_deflate_stream_free(&o->stream); } - efree(o); + freeObject(o); } /* {{{ proto void HttpDeflateStream::__construct([int flags = 0]) @@ -148,7 +153,7 @@ PHP_METHOD(HttpDeflateStream, __construct) getObject(http_deflatestream_object, obj); if (!obj->stream) { - obj->stream = http_encoding_deflate_stream_init(NULL, flags); + obj->stream = http_encoding_deflate_stream_init(NULL, flags & 0x0fffffff); } else { http_error_ex(HE_WARNING, HTTP_E_ENCODING, "HttpDeflateStream cannot be initialized twice"); }