diff options
author | Dmitry Stogov <dmitry@zend.com> | 2015-03-04 02:05:28 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2015-03-04 02:05:28 +0300 |
commit | 2fa8d67a5ce59ba9ba6192481e3c2522c3ff5542 (patch) | |
tree | 9d9d57215f756c387722e74d7d1e1c2de3276a1c /ext/bz2 | |
parent | 2841aa95db84f3563c94c90f84bf7f47ba159a2d (diff) | |
download | php-git-2fa8d67a5ce59ba9ba6192481e3c2522c3ff5542.tar.gz |
Use zend_string* instead of char* for opened_patch handling. Avoid reallocations and improve string reuse.
Diffstat (limited to 'ext/bz2')
-rw-r--r-- | ext/bz2/bz2.c | 18 | ||||
-rw-r--r-- | ext/bz2/php_bz2.h | 2 |
2 files changed, 4 insertions, 16 deletions
diff --git a/ext/bz2/bz2.c b/ext/bz2/bz2.c index 9b59942f26..969c5e131c 100644 --- a/ext/bz2/bz2.c +++ b/ext/bz2/bz2.c @@ -235,7 +235,7 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, - char **opened_path, + zend_string **opened_path, php_stream_context *context STREAMS_DC) { php_stream *retstream = NULL, *stream = NULL; @@ -266,20 +266,8 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, bz_file = BZ2_bzopen(path_copy, mode); if (opened_path && bz_file) { -#ifdef VIRTUAL_DIR - *opened_path = path_copy; - path_copy = NULL; -#else - *opened_path = estrdup(path_copy); -#endif - } - -#ifdef VIRTUAL_DIR - if (path_copy) { - efree(path_copy); + *opened_path = zend_string_init(path_copy, strlen(path_copy), 0); } -#endif - path_copy = NULL; if (bz_file == NULL) { /* that didn't work, so try and get something from the network/wrapper */ @@ -296,7 +284,7 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, * failed. */ if (opened_path && !bz_file && mode[0] == 'w') { - VCWD_UNLINK(*opened_path); + VCWD_UNLINK((*opened_path)->val); } } diff --git a/ext/bz2/php_bz2.h b/ext/bz2/php_bz2.h index b3c0725086..b1aa4ca97c 100644 --- a/ext/bz2/php_bz2.h +++ b/ext/bz2/php_bz2.h @@ -47,7 +47,7 @@ extern zend_module_entry bz2_module_entry; # define PHP_BZ2_API #endif -PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC); +PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper, const char *path, const char *mode, int options, zend_string **opened_path, php_stream_context *context STREAMS_DC); PHP_BZ2_API php_stream *_php_stream_bz2open_from_BZFILE(BZFILE *bz, const char *mode, php_stream *innerstream STREAMS_DC); #define php_stream_bz2open_from_BZFILE(bz, mode, innerstream) _php_stream_bz2open_from_BZFILE((bz), (mode), (innerstream) STREAMS_CC) |