diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2017-11-25 16:07:51 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2017-11-25 17:12:37 +0100 |
commit | b72b1a4e4d4a94a16b953bf8d826885efb56eeca (patch) | |
tree | d79e5390c77d3a5218f39262f2205280dacb8bf7 /ext/fileinfo/fileinfo.c | |
parent | 8795893f4f90a344cc9a9d48523b7aa0ba5ebf05 (diff) | |
download | php-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.
Diffstat (limited to 'ext/fileinfo/fileinfo.c')
-rw-r--r-- | ext/fileinfo/fileinfo.c | 2 |
1 files changed, 1 insertions, 1 deletions
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); |