Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ddfc55e

Browse files
committed
Apply changes from PR phpredis#966
1 parent 1cb4e07 commit ddfc55e

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

library.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,12 +1193,9 @@ static void array_zip_values_and_scores(RedisSock *redis_sock, zval *z_tab,
11931193
zend_hash_move_forward(keytable)) {
11941194

11951195
char *hkey, *hval;
1196-
zend_string *tablekey;
11971196
int hkey_len;
1198-
zend_ulong idx;
11991197
zval *z_key_p, *z_value_p;
12001198

1201-
zend_hash_get_current_key(keytable, &tablekey, &idx);
12021199
if((z_key_p = zend_hash_get_current_data(keytable)) == NULL) {
12031200
continue; /* this should never happen, according to the PHP people. */
12041201
}
@@ -1212,7 +1209,6 @@ static void array_zip_values_and_scores(RedisSock *redis_sock, zval *z_tab,
12121209
zend_hash_move_forward(keytable);
12131210

12141211
/* fetch again */
1215-
zend_hash_get_current_key(keytable, &tablekey, &idx);
12161212
if((z_value_p = zend_hash_get_current_data(keytable)) == NULL) {
12171213
continue; /* this should never happen, according to the PHP people. */
12181214
}

redis_array.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ PHP_METHOD(RedisArray, mget)
829829
RedisArray *ra;
830830
int *pos, argc, *argc_each;
831831
HashTable *h_keys;
832-
zval **redis_instances, **argv;
832+
zval **argv;
833833

834834
/* Multi/exec support */
835835
HANDLE_MULTI_EXEC("MGET");
@@ -851,7 +851,6 @@ PHP_METHOD(RedisArray, mget)
851851
argc = zend_hash_num_elements(h_keys);
852852
pos = emalloc(argc * sizeof(int));
853853

854-
redis_instances = ecalloc(argc, sizeof(zval*));
855854
argv = emalloc(argc * sizeof(zval*));
856855

857856
argc_each = emalloc(ra->count * sizeof(int));
@@ -869,7 +868,6 @@ PHP_METHOD(RedisArray, mget)
869868
php_error_docref(NULL TSRMLS_CC, E_ERROR, "MGET: all keys must be strings or longs");
870869
efree(argv);
871870
efree(pos);
872-
efree(redis_instances);
873871
efree(argc_each);
874872
RETURN_FALSE;
875873
}
@@ -884,7 +882,9 @@ PHP_METHOD(RedisArray, mget)
884882
}
885883

886884
/* Find our node */
887-
redis_instances[i] = ra_find_node(ra, key_lookup, key_len, &pos[i] TSRMLS_CC);
885+
if (ra_find_node(ra, key_lookup, key_len, &pos[i] TSRMLS_CC) == NULL) {
886+
/* TODO: handle */
887+
}
888888

889889
argc_each[pos[i]]++; /* count number of keys per node */
890890
argv[i] = data;
@@ -925,7 +925,6 @@ PHP_METHOD(RedisArray, mget)
925925
zval_dtor(&z_fun);
926926
zval_ptr_dtor(&z_tmp_array);
927927
efree(pos);
928-
efree(redis_instances);
929928
efree(argc_each);
930929

931930
/* failure */
@@ -958,7 +957,6 @@ PHP_METHOD(RedisArray, mget)
958957
zval_dtor(&z_fun);
959958
efree(argv);
960959
efree(pos);
961-
efree(redis_instances);
962960
efree(argc_each);
963961
}
964962

@@ -970,7 +968,7 @@ PHP_METHOD(RedisArray, mset)
970968
RedisArray *ra;
971969
int *pos, argc, *argc_each;
972970
HashTable *h_keys;
973-
zval *redis_inst, **redis_instances, **argv;
971+
zval *redis_inst, **argv;
974972
char *key, **keys, **key_free, kbuf[40];
975973
zend_string *key_zstr;
976974
unsigned int key_len;
@@ -998,7 +996,6 @@ PHP_METHOD(RedisArray, mset)
998996
key_lens = emalloc(argc * sizeof(int));
999997

1000998
argv = emalloc(argc * sizeof(zval*));
1001-
redis_instances = ecalloc(argc, sizeof(zval*));
1002999

10031000
/* Allocate an array holding the indexes of any keys that need freeing */
10041001
key_free = emalloc(argc * sizeof(char*));
@@ -1029,7 +1026,9 @@ PHP_METHOD(RedisArray, mset)
10291026
key = key_zstr->val;
10301027
}
10311028

1032-
redis_instances[i] = ra_find_node(ra, key, (int)key_len, &pos[i] TSRMLS_CC);
1029+
if (ra_find_node(ra, key, (int)key_len, &pos[i] TSRMLS_CC) == NULL) {
1030+
/* TODO: handle */
1031+
}
10331032
argc_each[pos[i]]++; /* count number of keys per node */
10341033
argv[i] = data;
10351034
keys[i] = key;
@@ -1095,7 +1094,6 @@ PHP_METHOD(RedisArray, mset)
10951094
efree(key_lens);
10961095
efree(argv);
10971096
efree(pos);
1098-
efree(redis_instances);
10991097
efree(argc_each);
11001098

11011099
RETURN_TRUE;
@@ -1109,7 +1107,7 @@ PHP_METHOD(RedisArray, del)
11091107
RedisArray *ra;
11101108
int *pos, argc, *argc_each;
11111109
HashTable *h_keys;
1112-
zval *redis_inst, **redis_instances, **argv;;
1110+
zval *redis_inst, **argv;;
11131111
long total = 0;
11141112
int free_zkeys = 0;
11151113

@@ -1152,7 +1150,6 @@ PHP_METHOD(RedisArray, del)
11521150
pos = emalloc(argc * sizeof(int));
11531151

11541152
argv = emalloc(argc * sizeof(zval*));
1155-
redis_instances = ecalloc(argc, sizeof(zval*));
11561153

11571154
argc_each = emalloc(ra->count * sizeof(int));
11581155
memset(argc_each, 0, ra->count * sizeof(int));
@@ -1166,7 +1163,9 @@ PHP_METHOD(RedisArray, del)
11661163
RETURN_FALSE;
11671164
}
11681165

1169-
redis_instances[i] = ra_find_node(ra, Z_STRVAL_P(data), Z_STRLEN_P(data), &pos[i] TSRMLS_CC);
1166+
if (ra_find_node(ra, Z_STRVAL_P(data), Z_STRLEN_P(data), &pos[i] TSRMLS_CC) == NULL) {
1167+
/* TODO: handle */
1168+
}
11701169
argc_each[pos[i]]++; /* count number of keys per node */
11711170
argv[i] = data;
11721171
i++;
@@ -1218,7 +1217,6 @@ PHP_METHOD(RedisArray, del)
12181217
/* cleanup */
12191218
efree(argv);
12201219
efree(pos);
1221-
efree(redis_instances);
12221220
efree(argc_each);
12231221

12241222
if(free_zkeys) {
@@ -1327,4 +1325,4 @@ PHP_METHOD(RedisArray, unwatch)
13271325
ra_index_unwatch(ra->z_multi_exec, return_value TSRMLS_CC);
13281326
}
13291327

1330-
/* vim: set tabstop=4 softtabstop=4 noexpandtab shiftwidth=4: */
1328+
/* vim: set tabstop=4 softtabstop=4 expandtab shiftwidth=4: */

0 commit comments

Comments
 (0)