summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2017-11-25 16:07:51 +0100
committerNikita Popov <nikita.ppv@gmail.com>2017-11-25 17:12:37 +0100
commitb72b1a4e4d4a94a16b953bf8d826885efb56eeca (patch)
treed79e5390c77d3a5218f39262f2205280dacb8bf7
parent8795893f4f90a344cc9a9d48523b7aa0ba5ebf05 (diff)
downloadphp-git-b72b1a4e4d4a94a16b953bf8d826885efb56eeca.tar.gz
Add zend_object_alloc() API
Using ecalloc() to create objects is expensive, because the dynamic-size memset() is unreasonably slow. Make sure we only zero the main object structure with known size, as the properties are intialized separately anyway. Technically we do not need to zero the embedded zend_object structure either, but as long as the memset argument is constant, a couple more bytes don't really matter.
-rw-r--r--Zend/zend_objects_API.h9
-rw-r--r--ext/date/php_date.c16
-rw-r--r--ext/dom/php_dom.c4
-rw-r--r--ext/fileinfo/fileinfo.c2
-rw-r--r--ext/hash/hash.c6
-rw-r--r--ext/intl/collator/collator_class.c4
-rw-r--r--ext/intl/converter/converter.c5
-rw-r--r--ext/intl/dateformat/dateformat_class.c3
-rw-r--r--ext/intl/formatter/formatter_class.c2
-rw-r--r--ext/intl/msgformat/msgformat_class.c2
-rw-r--r--ext/intl/resourcebundle/resourcebundle_class.c2
-rw-r--r--ext/intl/spoofchecker/spoofchecker_class.c5
-rw-r--r--ext/intl/transliterator/transliterator_class.c5
-rw-r--r--ext/mysqli/mysqli.c2
-rw-r--r--ext/pdo/pdo_dbh.c2
-rw-r--r--ext/pdo/pdo_stmt.c4
-rw-r--r--ext/reflection/php_reflection.c5
-rw-r--r--ext/simplexml/simplexml.c2
-rw-r--r--ext/snmp/snmp.c2
-rw-r--r--ext/spl/spl_array.c2
-rw-r--r--ext/spl/spl_directory.c2
-rw-r--r--ext/spl/spl_dllist.c2
-rw-r--r--ext/spl/spl_fixedarray.c2
-rw-r--r--ext/spl/spl_heap.c2
-rw-r--r--ext/spl/spl_iterators.c4
-rw-r--r--ext/sqlite3/sqlite3.c6
-rw-r--r--ext/tidy/tidy.c2
-rw-r--r--ext/xmlreader/php_xmlreader.c2
-rw-r--r--ext/xmlwriter/php_xmlwriter.c2
-rw-r--r--ext/xsl/php_xsl.c2
-rw-r--r--ext/zip/php_zip.c2
31 files changed, 53 insertions, 59 deletions
diff --git a/Zend/zend_objects_API.h b/Zend/zend_objects_API.h
index c21d1a3b0a..cffd9ee273 100644
--- a/Zend/zend_objects_API.h
+++ b/Zend/zend_objects_API.h
@@ -86,6 +86,15 @@ static zend_always_inline size_t zend_object_properties_size(zend_class_entry *c
((ce->ce_flags & ZEND_ACC_USE_GUARDS) ? 0 : 1));
}
+/* Allocates object type and zeros it, but not the properties.
+ * Properties MUST be initialized using object_properties_init(). */
+static zend_always_inline void *zend_object_alloc(size_t obj_size, zend_class_entry *ce) {
+ void *obj = emalloc(obj_size + zend_object_properties_size(ce));
+ memset(obj, 0, obj_size);
+ return obj;
+}
+
+
#endif /* ZEND_OBJECTS_H */
/*
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 6c26dfade3..b3f409f5f1 100644
--- a/ext/date/php_date.c
+++ b/ext/date/php_date.c
@@ -2187,9 +2187,7 @@ static void date_register_classes(void) /* {{{ */
static inline zend_object *date_object_new_date_ex(zend_class_entry *class_type, int init_props) /* {{{ */
{
- php_date_obj *intern;
-
- intern = ecalloc(1, sizeof(php_date_obj) + zend_object_properties_size(class_type));
+ php_date_obj *intern = zend_object_alloc(sizeof(php_date_obj), class_type);
zend_object_std_init(&intern->std, class_type);
if (init_props) {
@@ -2318,9 +2316,7 @@ static HashTable *date_object_get_properties(zval *object) /* {{{ */
static inline zend_object *date_object_new_timezone_ex(zend_class_entry *class_type, int init_props) /* {{{ */
{
- php_timezone_obj *intern;
-
- intern = ecalloc(1, sizeof(php_timezone_obj) + zend_object_properties_size(class_type));
+ php_timezone_obj *intern = zend_object_alloc(sizeof(php_timezone_obj), class_type);
zend_object_std_init(&intern->std, class_type);
if (init_props) {
@@ -2409,9 +2405,7 @@ static HashTable *date_object_get_properties_timezone(zval *object) /* {{{ */
static inline zend_object *date_object_new_interval_ex(zend_class_entry *class_type, int init_props) /* {{{ */
{
- php_interval_obj *intern;
-
- intern = ecalloc(1, sizeof(php_interval_obj) + zend_object_properties_size(class_type));
+ php_interval_obj *intern = zend_object_alloc(sizeof(php_interval_obj), class_type);
zend_object_std_init(&intern->std, class_type);
if (init_props) {
@@ -2495,9 +2489,7 @@ static HashTable *date_object_get_properties_interval(zval *object) /* {{{ */
static inline zend_object *date_object_new_period_ex(zend_class_entry *class_type, int init_props) /* {{{ */
{
- php_period_obj *intern;
-
- intern = ecalloc(1, sizeof(php_period_obj) + zend_object_properties_size(class_type));
+ php_period_obj *intern = zend_object_alloc(sizeof(php_period_obj), class_type);
zend_object_std_init(&intern->std, class_type);
if (init_props) {
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c
index 8fdf6aa6e0..109f7c127a 100644
--- a/ext/dom/php_dom.c
+++ b/ext/dom/php_dom.c
@@ -1075,7 +1075,7 @@ void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xml
static dom_object* dom_objects_set_class(zend_class_entry *class_type, zend_bool hash_copy) /* {{{ */
{
- dom_object *intern = ecalloc(1, sizeof(dom_object) + zend_object_properties_size(class_type));
+ dom_object *intern = zend_object_alloc(sizeof(dom_object), class_type);
zend_class_entry *base_class = class_type;
while ((base_class->type != ZEND_INTERNAL_CLASS || base_class->info.internal.module->module_number != dom_module_entry.module_number) && base_class->parent != NULL) {
@@ -1106,7 +1106,7 @@ zend_object *dom_objects_new(zend_class_entry *class_type)
/* {{{ zend_object dom_xpath_objects_new(zend_class_entry *class_type) */
zend_object *dom_xpath_objects_new(zend_class_entry *class_type)
{
- dom_xpath_object *intern = ecalloc(1, sizeof(dom_xpath_object) + zend_object_properties_size(class_type));
+ dom_xpath_object *intern = zend_object_alloc(sizeof(dom_xpath_object), class_type);
intern->registered_phpfunctions = zend_new_array(0);
diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c
index dcc8964635..9fbf51087d 100644
--- a/ext/fileinfo/fileinfo.c
+++ b/ext/fileinfo/fileinfo.c
@@ -100,7 +100,7 @@ PHP_FILEINFO_API zend_object *finfo_objects_new(zend_class_entry *class_type)
{
finfo_object *intern;
- intern = ecalloc(1, sizeof(finfo_object) + zend_object_properties_size(class_type));
+ intern = zend_object_alloc(sizeof(finfo_object), class_type);
zend_object_std_init(&intern->zo, class_type);
object_properties_init(&intern->zo, class_type);
diff --git a/ext/hash/hash.c b/ext/hash/hash.c
index d8e95ea1a0..c7c457945e 100644
--- a/ext/hash/hash.c
+++ b/ext/hash/hash.c
@@ -1106,11 +1106,11 @@ PHP_FUNCTION(mhash_keygen_s2k)
/* {{{ php_hashcontext_create */
static zend_object* php_hashcontext_create(zend_class_entry *ce) {
- php_hashcontext_object *objval = ecalloc(1,
- sizeof(php_hashcontext_object) + zend_object_properties_size(ce));
- zend_object *zobj = &(objval->std);
+ php_hashcontext_object *objval = zend_object_alloc(sizeof(php_hashcontext_object), ce);
+ zend_object *zobj = &objval->std;
zend_object_std_init(zobj, ce);
+ object_properties_init(zobj, ce);
zobj->handlers = &php_hashcontext_handlers;
return zobj;
diff --git a/ext/intl/collator/collator_class.c b/ext/intl/collator/collator_class.c
index d77a3432b8..fd2a616feb 100644
--- a/ext/intl/collator/collator_class.c
+++ b/ext/intl/collator/collator_class.c
@@ -49,9 +49,7 @@ void Collator_objects_free(zend_object *object )
/* {{{ Collator_object_create */
zend_object *Collator_object_create(zend_class_entry *ce )
{
- Collator_object* intern;
-
- intern = ecalloc(1, sizeof(Collator_object) + zend_object_properties_size(ce));
+ Collator_object *intern = zend_object_alloc(sizeof(Collator_object), ce);
intl_error_init(COLLATOR_ERROR_P(intern));
zend_object_std_init(&intern->zo, ce );
object_properties_init(&intern->zo, ce);
diff --git a/ext/intl/converter/converter.c b/ext/intl/converter/converter.c
index b893b8fd0a..bab4bb9881 100644
--- a/ext/intl/converter/converter.c
+++ b/ext/intl/converter/converter.c
@@ -1018,9 +1018,10 @@ static void php_converter_dtor_object(zend_object *obj) {
static zend_object *php_converter_object_ctor(zend_class_entry *ce, php_converter_object **pobjval) {
php_converter_object *objval;
- objval = ecalloc(1, sizeof(php_converter_object) + zend_object_properties_size(ce));
+ objval = zend_object_alloc(sizeof(php_converter_object), ce);
- zend_object_std_init(&objval->obj, ce );
+ zend_object_std_init(&objval->obj, ce);
+ object_properties_init(&objval->obj, ce);
intl_error_init(&(objval->error));
objval->obj.handlers = &php_converter_object_handlers;
diff --git a/ext/intl/dateformat/dateformat_class.c b/ext/intl/dateformat/dateformat_class.c
index 572a3b37d5..378c5a8be1 100644
--- a/ext/intl/dateformat/dateformat_class.c
+++ b/ext/intl/dateformat/dateformat_class.c
@@ -61,7 +61,7 @@ zend_object *IntlDateFormatter_object_create(zend_class_entry *ce)
{
IntlDateFormatter_object* intern;
- intern = ecalloc( 1, sizeof(IntlDateFormatter_object) + zend_object_properties_size(ce));
+ intern = zend_object_alloc(sizeof(IntlDateFormatter_object), ce);
dateformat_data_init( &intern->datef_data );
zend_object_std_init( &intern->zo, ce );
object_properties_init(&intern->zo, ce);
@@ -70,7 +70,6 @@ zend_object *IntlDateFormatter_object_create(zend_class_entry *ce)
intern->calendar = -1;
intern->requested_locale = NULL;
-
intern->zo.handlers = &IntlDateFormatter_handlers;
return &intern->zo;
diff --git a/ext/intl/formatter/formatter_class.c b/ext/intl/formatter/formatter_class.c
index ef54de9418..d15311201e 100644
--- a/ext/intl/formatter/formatter_class.c
+++ b/ext/intl/formatter/formatter_class.c
@@ -49,7 +49,7 @@ zend_object *NumberFormatter_object_create(zend_class_entry *ce)
{
NumberFormatter_object* intern;
- intern = ecalloc( 1, sizeof(NumberFormatter_object) + zend_object_properties_size(ce));
+ intern = zend_object_alloc(sizeof(NumberFormatter_object), ce);
formatter_data_init( &intern->nf_data );
zend_object_std_init( &intern->zo, ce );
object_properties_init(&intern->zo, ce);
diff --git a/ext/intl/msgformat/msgformat_class.c b/ext/intl/msgformat/msgformat_class.c
index 954dcfd3fd..aa7b839904 100644
--- a/ext/intl/msgformat/msgformat_class.c
+++ b/ext/intl/msgformat/msgformat_class.c
@@ -49,7 +49,7 @@ zend_object *MessageFormatter_object_create(zend_class_entry *ce)
{
MessageFormatter_object* intern;
- intern = ecalloc( 1, sizeof(MessageFormatter_object) + zend_object_properties_size(ce));
+ intern = zend_object_alloc(sizeof(MessageFormatter_object), ce);
msgformat_data_init( &intern->mf_data );
zend_object_std_init( &intern->zo, ce );
object_properties_init(&intern->zo, ce);
diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c
index f9d4bb16ca..3850a3b22e 100644
--- a/ext/intl/resourcebundle/resourcebundle_class.c
+++ b/ext/intl/resourcebundle/resourcebundle_class.c
@@ -57,7 +57,7 @@ static zend_object *ResourceBundle_object_create( zend_class_entry *ce )
{
ResourceBundle_object *rb;
- rb = ecalloc( 1, sizeof(ResourceBundle_object) + zend_object_properties_size(ce));
+ rb = zend_object_alloc(sizeof(ResourceBundle_object), ce);
zend_object_std_init( &rb->zend, ce );
object_properties_init( &rb->zend, ce);
diff --git a/ext/intl/spoofchecker/spoofchecker_class.c b/ext/intl/spoofchecker/spoofchecker_class.c
index ab41a00490..8b4274d374 100644
--- a/ext/intl/spoofchecker/spoofchecker_class.c
+++ b/ext/intl/spoofchecker/spoofchecker_class.c
@@ -41,12 +41,11 @@ void Spoofchecker_objects_free(zend_object *object)
/* }}} */
/* {{{ Spoofchecker_object_create */
-zend_object *Spoofchecker_object_create(
- zend_class_entry *ce)
+zend_object *Spoofchecker_object_create(zend_class_entry *ce)
{
Spoofchecker_object* intern;
- intern = ecalloc(1, sizeof(Spoofchecker_object) + zend_object_properties_size(ce));
+ intern = zend_object_alloc(sizeof(Spoofchecker_object), ce);
intl_error_init(SPOOFCHECKER_ERROR_P(intern));
zend_object_std_init(&intern->zo, ce);
object_properties_init(&intern->zo, ce);
diff --git a/ext/intl/transliterator/transliterator_class.c b/ext/intl/transliterator/transliterator_class.c
index 9eb2304c5e..ca174e2e70 100644
--- a/ext/intl/transliterator/transliterator_class.c
+++ b/ext/intl/transliterator/transliterator_class.c
@@ -109,12 +109,11 @@ static void Transliterator_objects_free( zend_object *object )
/* }}} */
/* {{{ Transliterator_object_create */
-static zend_object *Transliterator_object_create(
- zend_class_entry *ce )
+static zend_object *Transliterator_object_create( zend_class_entry *ce )
{
Transliterator_object* intern;
- intern = ecalloc( 1, sizeof( Transliterator_object ) + zend_object_properties_size(ce));
+ intern = zend_object_alloc(sizeof(Transliterator_object), ce);
zend_object_std_init( &intern->zo, ce );
object_properties_init( &intern->zo, ce );
diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c
index 58d55fe301..c8d8bd44f5 100644
--- a/ext/mysqli/mysqli.c
+++ b/ext/mysqli/mysqli.c
@@ -448,7 +448,7 @@ PHP_MYSQLI_EXPORT(zend_object *) mysqli_objects_new(zend_class_entry *class_type
zend_class_entry *mysqli_base_class;
zend_object_handlers *handlers;
- intern = ecalloc(1, sizeof(mysqli_object) + zend_object_properties_size(class_type));
+ intern = zend_object_alloc(sizeof(mysqli_object), class_type);
mysqli_base_class = class_type;
while (mysqli_base_class->type != ZEND_INTERNAL_CLASS &&
diff --git a/ext/pdo/pdo_dbh.c b/ext/pdo/pdo_dbh.c
index bfb65f48e2..57659967fc 100644
--- a/ext/pdo/pdo_dbh.c
+++ b/ext/pdo/pdo_dbh.c
@@ -1554,7 +1554,7 @@ zend_object *pdo_dbh_new(zend_class_entry *ce)
{
pdo_dbh_object_t *dbh;
- dbh = ecalloc(1, sizeof(pdo_dbh_object_t) + zend_object_properties_size(ce));
+ dbh = zend_object_alloc(sizeof(pdo_dbh_object_t), ce);
zend_object_std_init(&dbh->std, ce);
object_properties_init(&dbh->std, ce);
rebuild_object_properties(&dbh->std);
diff --git a/ext/pdo/pdo_stmt.c b/ext/pdo/pdo_stmt.c
index c1c1b01ba5..33f99b425a 100644
--- a/ext/pdo/pdo_stmt.c
+++ b/ext/pdo/pdo_stmt.c
@@ -2267,7 +2267,7 @@ static zend_object *dbstmt_clone_obj(zval *zobject)
pdo_stmt_t *stmt;
pdo_stmt_t *old_stmt;
- stmt = ecalloc(1, sizeof(pdo_stmt_t) + zend_object_properties_size(Z_OBJCE_P(zobject)));
+ stmt = zend_object_alloc(sizeof(pdo_stmt_t), Z_OBJCE_P(zobject));
zend_object_std_init(&stmt->std, Z_OBJCE_P(zobject));
object_properties_init(&stmt->std, Z_OBJCE_P(zobject));
@@ -2375,7 +2375,7 @@ zend_object *pdo_dbstmt_new(zend_class_entry *ce)
{
pdo_stmt_t *stmt;
- stmt = ecalloc(1, sizeof(pdo_stmt_t) + zend_object_properties_size(ce));
+ stmt = zend_object_alloc(sizeof(pdo_stmt_t), ce);
zend_object_std_init(&stmt->std, ce);
object_properties_init(&stmt->std, ce);
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 749c7e7656..d6b6d9718e 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -270,10 +270,7 @@ static HashTable *reflection_get_gc(zval *obj, zval **gc_data, int *gc_data_coun
static zend_object *reflection_objects_new(zend_class_entry *class_type) /* {{{ */
{
- reflection_object *intern;
-
- intern = ecalloc(1, sizeof(reflection_object) + zend_object_properties_size(class_type));
- intern->zo.ce = class_type;
+ reflection_object *intern = zend_object_alloc(sizeof(reflection_object), class_type);
zend_object_std_init(&intern->zo, class_type);
object_properties_init(&intern->zo, class_type);
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index a3defee4db..ece2d0020c 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -2166,7 +2166,7 @@ static php_sxe_object* php_sxe_object_new(zend_class_entry *ce, zend_function *f
{
php_sxe_object *intern;
- intern = ecalloc(1, sizeof(php_sxe_object) + zend_object_properties_size(ce));
+ intern = zend_object_alloc(sizeof(php_sxe_object), ce);
intern->iter.type = SXE_ITER_NONE;
intern->iter.nsprefix = NULL;
diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c
index a622dd0574..d180a73a46 100644
--- a/ext/snmp/snmp.c
+++ b/ext/snmp/snmp.c
@@ -475,7 +475,7 @@ static zend_object *php_snmp_object_new(zend_class_entry *class_type) /* {{{ */
php_snmp_object *intern;
/* Allocate memory for it */
- intern = ecalloc(1, sizeof(php_snmp_object) + zend_object_properties_size(class_type));
+ intern = zend_object_alloc(sizeof(php_snmp_object), class_type);
zend_object_std_init(&intern->zo, class_type);
object_properties_init(&intern->zo, class_type);
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index a9645ec61d..4e7faa404a 100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -173,7 +173,7 @@ static zend_object *spl_array_object_new_ex(zend_class_entry *class_type, zval *
zend_class_entry *parent = class_type;
int inherited = 0;
- intern = ecalloc(1, sizeof(spl_array_object) + zend_object_properties_size(parent));
+ intern = zend_object_alloc(sizeof(spl_array_object), parent);
zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 943b5174a2..c320e9c110 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -157,7 +157,7 @@ static zend_object *spl_filesystem_object_new_ex(zend_class_entry *class_type)
{
spl_filesystem_object *intern;
- intern = ecalloc(1, sizeof(spl_filesystem_object) + zend_object_properties_size(class_type));
+ intern = zend_object_alloc(sizeof(spl_filesystem_object), class_type);
/* intern->type = SPL_FS_INFO; done by set 0 */
intern->file_class = spl_ce_SplFileObject;
intern->info_class = spl_ce_SplFileInfo;
diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c
index 1f594293cd..7b2f677d81 100644
--- a/ext/spl/spl_dllist.c
+++ b/ext/spl/spl_dllist.c
@@ -373,7 +373,7 @@ static zend_object *spl_dllist_object_new_ex(zend_class_entry *class_type, zval
zend_class_entry *parent = class_type;
int inherited = 0;
- intern = ecalloc(1, sizeof(spl_dllist_object) + zend_object_properties_size(parent));
+ intern = zend_object_alloc(sizeof(spl_dllist_object), parent);
zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c
index 20fe02fd74..cd2f2ac123 100644
--- a/ext/spl/spl_fixedarray.c
+++ b/ext/spl/spl_fixedarray.c
@@ -210,7 +210,7 @@ static zend_object *spl_fixedarray_object_new_ex(zend_class_entry *class_type, z
zend_class_entry *parent = class_type;
int inherited = 0;
- intern = ecalloc(1, sizeof(spl_fixedarray_object) + zend_object_properties_size(parent));
+ intern = zend_object_alloc(sizeof(spl_fixedarray_object), parent);
zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c
index 5fecbfd290..38ce4c6241 100644
--- a/ext/spl/spl_heap.c
+++ b/ext/spl/spl_heap.c
@@ -363,7 +363,7 @@ static zend_object *spl_heap_object_new_ex(zend_class_entry *class_type, zval *o
zend_class_entry *parent = class_type;
int inherited = 0;
- intern = ecalloc(1, sizeof(spl_heap_object) + zend_object_properties_size(parent));
+ intern = zend_object_alloc(sizeof(spl_heap_object), parent);
zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index da4af5a726..7d33aac322 100644
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -961,7 +961,7 @@ static zend_object *spl_RecursiveIteratorIterator_new_ex(zend_class_entry *class
{
spl_recursive_it_object *intern;
- intern = ecalloc(1, sizeof(spl_recursive_it_object) + zend_object_properties_size(class_type));
+ intern = zend_object_alloc(sizeof(spl_recursive_it_object), class_type);
if (init_prefix) {
smart_str_appendl(&intern->prefix[0], "", 0);
@@ -2360,7 +2360,7 @@ static zend_object *spl_dual_it_new(zend_class_entry *class_type)
{
spl_dual_it_object *intern;
- intern = ecalloc(1, sizeof(spl_dual_it_object) + zend_object_properties_size(class_type));
+ intern = zend_object_alloc(sizeof(spl_dual_it_object), class_type);
intern->dit_type = DIT_Unknown;
zend_object_std_init(&intern->std, class_type);
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
index 1b8f8e6e5f..54fa24387d 100644
--- a/ext/sqlite3/sqlite3.c
+++ b/ext/sqlite3/sqlite3.c
@@ -2204,7 +2204,7 @@ static zend_object *php_sqlite3_object_new(zend_class_entry *class_type) /* {{{
php_sqlite3_db_object *intern;
/* Allocate memory for it */
- intern = ecalloc(1, sizeof(php_sqlite3_db_object) + zend_object_properties_size(class_type));
+ intern = zend_object_alloc(sizeof(php_sqlite3_db_object), class_type);
/* Need to keep track of things to free */
zend_llist_init(&(intern->free_list), sizeof(php_sqlite3_free_list *), (llist_dtor_func_t)php_sqlite3_free_list_dtor, 0);
@@ -2223,7 +2223,7 @@ static zend_object *php_sqlite3_stmt_object_new(zend_class_entry *class_type) /*
php_sqlite3_stmt *intern;
/* Allocate memory for it */
- intern = ecalloc(1, sizeof(php_sqlite3_stmt) + zend_object_properties_size(class_type));
+ intern = zend_object_alloc(sizeof(php_sqlite3_stmt), class_type);
zend_object_std_init(&intern->zo, class_type);
object_properties_init(&intern->zo, class_type);
@@ -2239,7 +2239,7 @@ static zend_object *php_sqlite3_result_object_new(zend_class_entry *class_type)
php_sqlite3_result *intern;
/* Allocate memory for it */
- intern = ecalloc(1, sizeof(php_sqlite3_result) + zend_object_properties_size(class_type));
+ intern = zend_object_alloc(sizeof(php_sqlite3_result), class_type);
zend_object_std_init(&intern->zo, class_type);
object_properties_init(&intern->zo, class_type);
diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c
index 6a3270c9cb..895a8152d9 100644
--- a/ext/tidy/tidy.c
+++ b/ext/tidy/tidy.c
@@ -685,7 +685,7 @@ static zend_object *tidy_object_new(zend_class_entry *class_type, zend_object_ha
{
PHPTidyObj *intern;
- intern = ecalloc(1, sizeof(PHPTidyObj) + zend_object_properties_size(class_type));
+ intern = zend_object_alloc(sizeof(PHPTidyObj), class_type);
zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
diff --git a/ext/xmlreader/php_xmlreader.c b/ext/xmlreader/php_xmlreader.c
index 392d9b19c3..fbec784557 100644
--- a/ext/xmlreader/php_xmlreader.c
+++ b/ext/xmlreader/php_xmlreader.c
@@ -389,7 +389,7 @@ zend_object *xmlreader_objects_new(zend_class_entry *class_type)
{
xmlreader_object *intern;
- intern = ecalloc(1, sizeof(xmlreader_object) + zend_object_properties_size(class_type));
+ intern = zend_object_alloc(sizeof(xmlreader_object), class_type);
zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
intern->prop_handler = &xmlreader_prop_handlers;
diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c
index d7304fe548..3297351571 100644
--- a/ext/xmlwriter/php_xmlwriter.c
+++ b/ext/xmlwriter/php_xmlwriter.c
@@ -141,7 +141,7 @@ static zend_object *xmlwriter_object_new(zend_class_entry *class_type)
{
ze_xmlwriter_object *intern;
- intern = ecalloc(1, sizeof(ze_xmlwriter_object) + zend_object_properties_size(class_type));
+ intern = zend_object_alloc(sizeof(ze_xmlwriter_object), class_type);
zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
intern->std.handlers = &xmlwriter_object_handlers;
diff --git a/ext/xsl/php_xsl.c b/ext/xsl/php_xsl.c
index 61afc36099..52b5c9c7d8 100644
--- a/ext/xsl/php_xsl.c
+++ b/ext/xsl/php_xsl.c
@@ -108,7 +108,7 @@ zend_object *xsl_objects_new(zend_class_entry *class_type)
{
xsl_object *intern;
- intern = ecalloc(1, sizeof(xsl_object) + zend_object_properties_size(class_type));
+ intern = zend_object_alloc(sizeof(xsl_object), class_type);
intern->securityPrefs = XSL_SECPREF_DEFAULT;
zend_object_std_init(&intern->std, class_type);
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index b3d72678e3..c20a059467 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -1064,7 +1064,7 @@ static zend_object *php_zip_object_new(zend_class_entry *class_type) /* {{{ */
{
ze_zip_object *intern;
- intern = ecalloc(1, sizeof(ze_zip_object) + zend_object_properties_size(class_type));
+ intern = zend_object_alloc(sizeof(ze_zip_object), class_type);
intern->prop_handler = &zip_prop_handlers;
zend_object_std_init(&intern->zo, class_type);
object_properties_init(&intern->zo, class_type);