10000 Fix compile time errors for redis_array_impl.c · chenyongze/phpredis@9221ca4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9221ca4

Browse files
committed
Fix compile time errors for redis_array_impl.c
1 parent 4e00df6 commit 9221ca4

File tree

4 files changed

+376
-445
lines changed

4 files changed

+376
-445
lines changed

redis_array.c

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -89,28 +89,28 @@ static void redis_array_free(RedisArray *ra) {
8989

9090
/* Redis objects */
9191
for(i=0;i<ra->count;i++) {
92-
zval_dtor(ra->redis[i]);
93-
efree(ra->redis[i]);
94-
efree(ra->hosts[i]);
92+
zval_dtor(&ra->redis[i]);
93+
efree(&ra->redis[i]);
94+
efree(&ra->hosts[i]);
9595
}
9696
efree(ra->redis);
9797
efree(ra->hosts);
9898

9999
/* delete hash function */
100-
if(ra->z_fun) {
101-
zval_dtor(ra->z_fun);
102-
efree(ra->z_fun);
100+
if(Z_TYPE(ra->z_fun) != IS_UNDEF) {
101+
zval_dtor(&ra->z_fun);
102+
efree(&ra->z_fun);
103103
}
104104

105105
/* Distributor */
106-
if(ra->z_dist) {
107-
zval_dtor(ra->z_dist);
108-
efree(ra->z_dist);
106+
if(Z_TYPE(ra->z_dist) != IS_UNDEF) {
107+
zval_dtor(&ra->z_dist);
108+
efree(&ra->z_dist);
109109
}
110110

111111
/* Delete pur commands */
112-
zval_dtor(ra->z_pure_cmds);
113-
efree(ra->z_pure_cmds);
112+
zval_dtor(&ra->z_pure_cmds);
113+
efree(&ra->z_pure_cmds);
114114

115115
/* Free structure itself */
116116
efree(ra);
@@ -515,9 +515,8 @@ PHP_METHOD(RedisArray, _function)
515515
RETURN_FALSE;
516516
}
517517

518-
if(ra->z_fun) {
519-
*return_value = *ra->z_fun;
520-
zval_copy_ctor(return_value);
518+
if(Z_TYPE(ra->z_fun) != IS_UNDEF) {
519+
ZVAL_DUP(return_value, &ra->z_fun);
521520
} else {
522521
RETURN_NULL();
523522
}
@@ -537,9 +536,8 @@ PHP_METHOD(RedisArray, _distributor)
537536
RETURN_FALSE;
538537
}
539538

540-
if(ra->z_fun) {
541-
*return_value = *ra->z_fun;
542-
zval_copy_ctor(return_value);
539+
if(Z_TYPE(ra->z_fun) != IS_UNDEF) {
540+
ZVAL_DUP(return_value, &ra->z_fun);
543541
} else {
544542
RETURN_NULL();
545543
}
@@ -592,8 +590,7 @@ static void multihost_distribute(INTERNAL_FUNCTION_PARAMETERS, const char *metho
592590
ZVAL_UNDEF(&z_tmp);
593591

594592
/* Call each node in turn */
595-
call_user_function(&redis_ce->function_table, ra->redis[i],
596-
&z_fun, &z_tmp, 0, NULL TSRMLS_CC);
593+
call_user_function(&redis_ce->function_table, &ra->redis[i], &z_fun, &z_tmp, 0, NULL TSRMLS_CC);
597594

598595
add_assoc_zval(return_value, ra->hosts[i], &z_tmp);
599596
}
@@ -664,7 +661,7 @@ PHP_METHOD(RedisArray, keys)
664661
ZVAL_UNDEF(&z_tmp);
665662

666663
/* Call KEYS on each node */
667-
call_user_function(&redis_ce->function_table, ra->redis[i], &z_fun, &z_tmp, 1, z_args TSRMLS_CC);
664+
call_user_function(&redis_ce->function_table, &ra->redis[i], &z_fun, &z_tmp, 1, z_args TSRMLS_CC);
668665

669666
/* Add the result for this host */
670667
add_assoc_zval(return_value, ra->hosts[i], &z_tmp);
@@ -702,7 +699,7 @@ PHP_METHOD(RedisArray, getOption)
702699
ZVAL_UNDEF(&z_tmp);
703700

704701
/* Call each node in turn */
705-
call_user_function(&redis_ce->function_table, ra->redis[i],
702+
call_user_function(&redis_ce->function_table, &ra->redis[i],
706703
&z_fun, &z_tmp, 1, z_args TSRMLS_CC);
707704

708705
add_assoc_zval(return_value, ra->hosts[i], &z_tmp);
@@ -743,7 +740,7 @@ PHP_METHOD(RedisArray, setOption)
743740
ZVAL_UNDEF(&z_tmp);
744741

745742
/* Call each node in turn */
746-
call_user_function(&redis_ce->function_table, ra->redis[i],
743+
call_user_function(&redis_ce->function_table, &ra->redis[i],
747744
&z_fun, &z_tmp, 2, z_args TSRMLS_CC);
748745

749746
add_assoc_zval(return_value, ra->hosts[i], &z_tmp);
@@ -782,7 +779,7 @@ PHP_METHOD(RedisArray, select)
782779
ZVAL_UNDEF(&z_tmp);
783780

784781
/* Call each node in turn */
785-
call_user_function(&redis_ce->function_table, ra->redis[i],
782+
call_user_function(&redis_ce->function_table, &ra->redis[i],
786783
&z_fun, &z_tmp, 1, z_args TSRMLS_CC);
787784

788785
add_assoc_zval(return_value, ra->hosts[i], &z_tm B41A p);
@@ -908,7 +905,7 @@ PHP_METHOD(RedisArray, mget)
908905
}
909906

910907
/* call MGET on the node */
911-
call_user_function(&redis_ce->function_table, ra->redis[n],
908+
call_user_function(&redis_ce->function_table, &ra->redis[n],
912909
&z_fun, &z_ret, 1, &z_argarray TSRMLS_CC);
913910

914911
/* cleanup args array */
@@ -1034,7 +1031,7 @@ PHP_METHOD(RedisArray, mset)
10341031

10351032
/* prepare call */
10361033
ZVAL_STRING(&z_fun, "MSET");
1037-
redis_inst = ra->redis[n];
1034+
redis_inst = &ra->redis[n];
10381035

10391036
/* copy args */
10401037
array_init(&z_argarray);
@@ -1061,7 +1058,7 @@ PHP_METHOD(RedisArray, mset)
10611058
}
10621059

10631060
/* call */
1064-
call_user_function(&redis_ce->function_table, ra->redis[n],
1061+
call_user_function(&redis_ce->function_table, &ra->redis[n],
10651062
&z_fun, &z_ret, 1, &z_argarray TSRMLS_CC);
10661063

10671064
if(ra->index) {
@@ -1166,7 +1163,7 @@ PHP_METHOD(RedisArray, del)
11661163
for(n = 0; n < ra->count; ++n) { /* for each node */
11671164

11681165
int found = 0;
1169-
redis_inst = ra->redis[n];
1166+
redis_inst = &ra->redis[n];
11701167

11711168
/* copy args */
11721169
array_init(&z_argarray);

redis_array.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ typedef struct RedisArray_ {
4343

4444
int count;
4545
char **hosts; /* array of host:port strings */
46-
zval **redis; /* array of Redis instances */
46+
zval *redis; /* array of Redis instances */
4747
zval *z_multi_exec; /* Redis instance to be used in multi-exec */
4848
zend_bool index; /* use per-node index */
4949
zend_bool auto_rehash; /* migrate keys on read operations */
5050
zend_bool pconnect; /* should we use pconnect */
51-
zval *z_fun; /* key extractor, callable */
52-
zval *z_dist; /* key distributor, callable */
53-
zval *z_pure_cmds; /* hash table */
51+
zval z_fun; /* key extractor, callable */
52+
zval z_dist; /* key distributor, callable */
53+
zval z_pure_cmds; /* hash table */
5454
double connect_timeout; /* socket connect timeout */
5555

5656
struct RedisArray_ *prev;

0 commit comments

Comments
 (0)
0