@@ -51,7 +51,7 @@ ra_load_hosts(RedisArray *ra, HashTable *hosts, long retry_interval, zend_bool b
5151 /* default values */
5252 host = Z_STRVAL_P (zpData );
5353 host_len = Z_STRLEN_P (zpData );
54- ra -> hosts [i ] = estrndup (host , host_len );
54+ ra -> hosts [i ] = zend_string_init (host , host_len , 0 );
5555 port = 6379 ;
5656
5757 if ((p = strrchr (host , ':' ))) { /* found port */
@@ -348,7 +348,7 @@ ra_make_array(HashTable *hosts, zval *z_fun, zval *z_dist, HashTable *hosts_prev
348348
349349 /* create object */
350350 ra = emalloc (sizeof (RedisArray ));
351- ra -> hosts = ecalloc (count , sizeof (char * ));
351+ ra -> hosts = ecalloc (count , sizeof (* ra -> hosts ));
352352 ra -> redis = ecalloc (count , sizeof (zval ));
353353 ra -> count = 0 ;
354354 ra -> z_multi_exec = NULL ;
@@ -361,7 +361,7 @@ ra_make_array(HashTable *hosts, zval *z_fun, zval *z_dist, HashTable *hosts_prev
361361 if (ra_load_hosts (ra , hosts , retry_interval , b_lazy_connect TSRMLS_CC ) == NULL || !ra -> count ) {
362362 for (i = 0 ; i < ra -> count ; ++ i ) {
363363 zval_dtor (& ra -> redis [i ]);
364- efree (ra -> hosts [i ]);
364+ zend_string_release (ra -> hosts [i ]);
365365 }
366366 efree (ra -> redis );
367367 efree (ra -> hosts );
@@ -500,7 +500,7 @@ ra_find_node_by_name(RedisArray *ra, const char *host, int host_len TSRMLS_DC) {
500500
501501 int i ;
502502 for (i = 0 ; i < ra -> count ; ++ i ) {
503- if ( strncmp (ra -> hosts [i ], host , host_len ) == 0 ) {
503+ if ( ZSTR_LEN (ra -> hosts [i ]) == host_len && strcmp ( ZSTR_VAL ( ra -> hosts [ i ]), host ) == 0 ) {
504504 return & ra -> redis [i ];
505505 }
506506 }
@@ -1079,7 +1079,7 @@ ra_move_key(const char *key, int key_len, zval *z_from, zval *z_to TSRMLS_DC) {
10791079/* callback with the current progress, with hostname and count */
10801080static void
10811081zval_rehash_callback (zend_fcall_info * z_cb , zend_fcall_info_cache * z_cb_cache ,
1082- const char * hostname , long count TSRMLS_DC ) {
1082+ zend_string * hostname , long count TSRMLS_DC ) {
10831083
10841084 zval zv , * z_ret = & zv ;
10851085
@@ -1088,7 +1088,7 @@ zval_rehash_callback(zend_fcall_info *z_cb, zend_fcall_info_cache *z_cb_cache,
10881088 zval * z_host , * z_count , * * z_args_pp [2 ];
10891089
10901090 MAKE_STD_ZVAL (z_host );
1091- ZVAL_STRING (z_host , hostname );
1091+ ZVAL_STRINGL (z_host , ZSTR_VAL ( hostname ), ZSTR_LEN ( hostname ) );
10921092 z_args_pp [0 ] = & z_host ;
10931093
10941094 MAKE_STD_ZVAL (z_count );
@@ -1100,7 +1100,7 @@ zval_rehash_callback(zend_fcall_info *z_cb, zend_fcall_info_cache *z_cb_cache,
11001100#else
11011101 zval z_args [2 ];
11021102
1103- ZVAL_STRING (& z_args [0 ], hostname );
1103+ ZVAL_STRINGL (& z_args [0 ], ZSTR_VAL ( hostname ), ZSTR_LEN ( hostname ) );
11041104 ZVAL_LONG (& z_args [1 ], count );
11051105
11061106 z_cb -> params = z_args ;
@@ -1123,7 +1123,7 @@ zval_rehash_callback(zend_fcall_info *z_cb, zend_fcall_info_cache *z_cb_cache,
11231123}
11241124
11251125static void
1126- ra_rehash_server (RedisArray * ra , zval * z_redis , const char * hostname , zend_bool b_index ,
1126+ ra_rehash_server (RedisArray * ra , zval * z_redis , zend_string * hostname , zend_bool b_index ,
11271127 zend_fcall_info * z_cb , zend_fcall_info_cache * z_cb_cache TSRMLS_DC ) {
11281128
11291129 HashTable * h_keys ;
@@ -1164,7 +1164,7 @@ ra_rehash_server(RedisArray *ra, zval *z_redis, const char *hostname, zend_bool
11641164 /* check that we're not moving to the same node. */
11651165 zval * z_target = ra_find_node (ra , Z_STRVAL_P (z_ele ), Z_STRLEN_P (z_ele ), & pos TSRMLS_CC );
11661166
1167- if (z_target && strcmp (hostname , ra -> hosts [pos ])) { /* different host */
1167+ if (z_target && zend_string_equals (hostname , ra -> hosts [pos ])) { /* different host */
11681168 ra_move_key (Z_STRVAL_P (z_ele ), Z_STRLEN_P (z_ele ), z_redis , z_target TSRMLS_CC );
11691169 }
11701170
0 commit comments