summaryrefslogtreecommitdiff
path: root/ext/spl/php_spl.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2014-08-21 12:02:48 +0400
committerDmitry Stogov <dmitry@zend.com>2014-08-21 12:02:48 +0400
commite9439f62e5e3696728accf21bf90b0c07fbed4df (patch)
treec1554dee44c8491e6defc220f1a6979e0c73b7e2 /ext/spl/php_spl.c
parent92ac625b94e3dc79a0c9def934c61d83397afe81 (diff)
downloadphp-git-e9439f62e5e3696728accf21bf90b0c07fbed4df.tar.gz
Avoid reallocation and copying
Diffstat (limited to 'ext/spl/php_spl.c')
-rw-r--r--ext/spl/php_spl.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index f9a642410f..5636a5f989 100644
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -742,22 +742,18 @@ PHP_FUNCTION(spl_autoload_functions)
PHP_FUNCTION(spl_object_hash)
{
zval *obj;
- char hash[33];
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &obj) == FAILURE) {
return;
}
- php_spl_object_hash(obj, hash TSRMLS_CC);
-
- RETURN_STRING(hash);
+ RETURN_NEW_STR(php_spl_object_hash(obj TSRMLS_CC));
}
/* }}} */
-PHPAPI void php_spl_object_hash(zval *obj, char *result TSRMLS_DC) /* {{{*/
+PHPAPI zend_string *php_spl_object_hash(zval *obj TSRMLS_DC) /* {{{*/
{
intptr_t hash_handle, hash_handlers;
- char *hex;
if (!SPL_G(hash_mask_init)) {
if (!BG(mt_rand_is_seeded)) {
@@ -772,10 +768,7 @@ PHPAPI void php_spl_object_hash(zval *obj, char *result TSRMLS_DC) /* {{{*/
hash_handle = SPL_G(hash_mask_handle)^(intptr_t)Z_OBJ_HANDLE_P(obj);
hash_handlers = SPL_G(hash_mask_handlers)^(intptr_t)Z_OBJ_HT_P(obj);
- spprintf(&hex, 32, "%016lx%016lx", hash_handle, hash_handlers);
-
- strlcpy(result, hex, 33);
- efree(hex);
+ return strpprintf(32, "%016lx%016lx", hash_handle, hash_handlers);
}
/* }}} */