Shave off a strlen() call in ftp_mkdir()

This commit is contained in:
Kalle Sommer Nielsen 2016-11-20 19:36:36 +01:00
parent d7deaac362
commit 06767ffcbe
3 changed files with 4 additions and 4 deletions

View File

@ -560,7 +560,7 @@ ftp_cdup(ftpbuf_t *ftp)
/* {{{ ftp_mkdir /* {{{ ftp_mkdir
*/ */
zend_string* zend_string*
ftp_mkdir(ftpbuf_t *ftp, const char *dir) ftp_mkdir(ftpbuf_t *ftp, const char *dir, const size_t dir_len)
{ {
char *mkd, *end; char *mkd, *end;
zend_string *ret; zend_string *ret;
@ -576,7 +576,7 @@ ftp_mkdir(ftpbuf_t *ftp, const char *dir)
} }
/* copy out the dir from response */ /* copy out the dir from response */
if ((mkd = strchr(ftp->inbuf, '"')) == NULL) { if ((mkd = strchr(ftp->inbuf, '"')) == NULL) {
return zend_string_init(dir, strlen(dir), 0); return zend_string_init(dir, dir_len, 0);
} }
if ((end = strrchr(++mkd, '"')) == NULL) { if ((end = strrchr(++mkd, '"')) == NULL) {
return NULL; return NULL;

View File

@ -135,7 +135,7 @@ int ftp_cdup(ftpbuf_t *ftp);
/* creates a directory, return the directory name on success, NULL on error. /* creates a directory, return the directory name on success, NULL on error.
* the return value must be freed * the return value must be freed
*/ */
zend_string* ftp_mkdir(ftpbuf_t *ftp, const char *dir); zend_string* ftp_mkdir(ftpbuf_t *ftp, const char *dir, const size_t dir_len);
/* removes a directory, return true on success, false on error */ /* removes a directory, return true on success, false on error */
int ftp_rmdir(ftpbuf_t *ftp, const char *dir); int ftp_rmdir(ftpbuf_t *ftp, const char *dir);

View File

@ -593,7 +593,7 @@ PHP_FUNCTION(ftp_mkdir)
} }
/* create directorie */ /* create directorie */
if (NULL == (tmp = ftp_mkdir(ftp, dir))) { if (NULL == (tmp = ftp_mkdir(ftp, dir, dir_len))) {
php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf); php_error_docref(NULL, E_WARNING, "%s", ftp->inbuf);
RETURN_FALSE; RETURN_FALSE;
} }