From: Antony Dovgal Date: Mon, 3 Apr 2006 14:59:30 +0000 (+0000) Subject: #ifdef new functions and use their bodies to make PECL extensions compile with PHP... X-Git-Tag: php-5.1.3RC3~100 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f510a6a9543988e690f54cb32744157a0f48bf1;p=php #ifdef new functions and use their bodies to make PECL extensions compile with PHP < 5.1.3 (as was agreed with Ilia) --- diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 42a365a05c..69cc4a6b58 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1785,8 +1785,20 @@ static void sxe_object_free_storage(void *object TSRMLS_DC) sxe = (php_sxe_object *) object; +#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 1 && PHP_RELEASE_VERSION > 2) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) zend_object_std_dtor(&sxe->zo TSRMLS_CC); - +#else + if (sxe->zo.guards) { + zend_hash_destroy(sxe->zo.guards); + FREE_HASHTABLE(sxe->zo.guards); + } + + if (sxe->zo.properties) { + zend_hash_destroy(sxe->zo.properties); + FREE_HASHTABLE(sxe->zo.properties); + } +#endif + php_libxml_node_decrement_resource((php_libxml_node_object *)sxe TSRMLS_CC); if (sxe->xpath) { @@ -1814,7 +1826,15 @@ static php_sxe_object* php_sxe_object_new(zend_class_entry *ce TSRMLS_DC) intern->iter.nsprefix = NULL; intern->iter.name = NULL; +#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 1 && PHP_RELEASE_VERSION > 2) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) zend_object_std_init(&intern->zo, ce TSRMLS_CC); +#else + ALLOC_HASHTABLE(intern->zo.properties); + zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0); + + intern->zo.ce = ce; + intern->zo.guards = NULL; +#endif return intern; } diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 81e8e0b069..43327bdaba 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -530,7 +530,19 @@ static void tidy_object_free_storage(void *object TSRMLS_DC) { PHPTidyObj *intern = (PHPTidyObj *)object; +#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 1 && PHP_RELEASE_VERSION > 2) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) zend_object_std_dtor(&intern->std TSRMLS_CC); +#else + if (intern->std.guards) { + zend_hash_destroy(intern->std.guards); + FREE_HASHTABLE(intern->std.guards); + } + + if (intern->std.properties) { + zend_hash_destroy(intern->std.properties); + FREE_HASHTABLE(intern->std.properties); + } +#endif if (intern->ptdoc) { intern->ptdoc->ref_count--; @@ -554,8 +566,16 @@ static void tidy_object_new(zend_class_entry *class_type, zend_object_handlers * intern = emalloc(sizeof(PHPTidyObj)); memset(intern, 0, sizeof(PHPTidyObj)); - +#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 1 && PHP_RELEASE_VERSION > 2) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) zend_object_std_init(&intern->std, class_type TSRMLS_CC); +#else + ALLOC_HASHTABLE(intern->std.properties); + zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0); + + intern->std.ce = class_type; + intern->std.guards = NULL; +#endif + zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); switch(objtype) { diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c index ca773dd03a..2768653543 100644 --- a/ext/xmlreader/php_xmlreader.c +++ b/ext/xmlreader/php_xmlreader.c @@ -377,8 +377,20 @@ void xmlreader_objects_free_storage(void *object TSRMLS_DC) { xmlreader_object *intern = (xmlreader_object *)object; +#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 1 && PHP_RELEASE_VERSION > 2) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) zend_object_std_dtor(&intern->std TSRMLS_CC); - +#else + if (intern->std.guards) { + zend_hash_destroy(intern->std.guards); + FREE_HASHTABLE(intern->std.guards); + } + + if (intern->std.properties) { + zend_hash_destroy(intern->std.properties); + FREE_HASHTABLE(intern->std.properties); + } +#endif + xmlreader_free_resources(intern); efree(object); @@ -398,7 +410,16 @@ zend_object_value xmlreader_objects_new(zend_class_entry *class_type TSRMLS_DC) intern->schema = NULL; intern->prop_handler = &xmlreader_prop_handlers; +#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 1 && PHP_RELEASE_VERSION > 2) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) zend_object_std_init(&intern->std, class_type TSRMLS_CC); +#else + ALLOC_HASHTABLE(intern->std.properties); + zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0); + + intern->std.ce = class_type; + intern->std.guards = NULL; +#endif + zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) xmlreader_objects_free_storage, xmlreader_objects_clone TSRMLS_CC); intern->handle = retval.handle; diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c index 05fc571feb..e204fcbb39 100644 --- a/ext/xmlwriter/php_xmlwriter.c +++ b/ext/xmlwriter/php_xmlwriter.c @@ -77,8 +77,21 @@ static void xmlwriter_object_free_storage(void *object TSRMLS_DC) xmlwriter_free_resource_ptr(intern->xmlwriter_ptr TSRMLS_CC); } intern->xmlwriter_ptr = NULL; + +#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 1 && PHP_RELEASE_VERSION > 2) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) zend_object_std_dtor(&intern->zo TSRMLS_CC); - +#else + if (intern->zo.guards) { + zend_hash_destroy(intern->zo.guards); + FREE_HASHTABLE(intern->zo.guards); + } + + if (intern->zo.properties) { + zend_hash_destroy(intern->zo.properties); + FREE_HASHTABLE(intern->zo.properties); + } +#endif + efree(intern); } /* }}} */ @@ -94,8 +107,17 @@ PHP_XMLWRITER_API zend_object_value xmlwriter_object_new(zend_class_entry *class intern = emalloc(sizeof(ze_xmlwriter_object)); memset(&intern->zo, 0, sizeof(zend_object)); intern->xmlwriter_ptr = NULL; - + +#if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 1 && PHP_RELEASE_VERSION > 2) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 1) || (PHP_MAJOR_VERSION > 5) zend_object_std_init(&intern->zo, class_type TSRMLS_CC); +#else + ALLOC_HASHTABLE(intern->zo.properties); + zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0); + + intern->zo.ce = class_type; + intern->zo.guards = NULL; +#endif + zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));