Cleanup (avoid reallocation).

This commit is contained in:
Dmitry Stogov 2015-07-01 14:08:54 +03:00
parent 34ec1c96e7
commit 7d82deab35

View File

@ -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);
}