From b72b1a4e4d4a94a16b953bf8d826885efb56eeca Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 25 Nov 2017 16:07:51 +0100 Subject: 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. --- ext/zip/php_zip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ext/zip/php_zip.c') 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); -- cgit v1.2.1