com php-src: Cleanup (avoid reallocation).: ext/spl/spl_direc tory.c
| From: | Dmitry Stogov | Date: | Wed, 01 Jul 2015 11:08:54 +0000 |
| Subject: | com php-src: Cleanup (avoid reallocation).: ext/spl/spl_direc tory.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87657@lists.php.net to get a copy of this message | ||
Commit: 7d82deab35806c7169d2e40116f236d16cc80f3f
Author: Dmitry Stogov <dmitry@zend.com> Wed, 1 Jul 2015 14:08:54 +0300
Parents: 34ec1c96e7125122b0cc069d31e237041dfc1067
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7d82deab35806c7169d2e40116f236d16cc80f3f
Log:
Cleanup (avoid reallocation).
Changed paths:
M ext/spl/spl_directory.c
Diff:
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index a7d8a32..bf23c64 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -1546,8 +1546,6 @@ SPL_METHOD(RecursiveDirectoryIterator, getSubPath)
SPL_METHOD(RecursiveDirectoryIterator, getSubPathname)
{
spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
- char *sub_name;
- size_t len;
char slash = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_UNIXPATHS) ? '/' :
DEFAULT_SLASH;
if (zend_parse_parameters_none() == FAILURE) {
@@ -1555,9 +1553,7 @@ SPL_METHOD(RecursiveDirectoryIterator, getSubPathname)
}
if (intern->u.dir.sub_path) {
- len = spprintf(&sub_name, 0, "%s%c%s", intern->u.dir.sub_path, slash,
intern->u.dir.entry.d_name);
- RETVAL_STRINGL(sub_name, len);
- efree(sub_name);
+ RETURN_NEW_STR(strpprintf(0, "%s%c%s", intern->u.dir.sub_path, slash,
intern->u.dir.entry.d_name));
} else {
RETURN_STRING(intern->u.dir.entry.d_name);
}