Skip to content

Commit b91ce69

Browse files
authored
Merge pull request phpredis#1034 from yatsukhnenko/develop
refactoring
2 parents f1a85b3 + 48c8f2a commit b91ce69

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

redis_cluster.c

+6-15
Original file line numberDiff line numberDiff line change
@@ -340,25 +340,15 @@ create_cluster_context(zend_class_entry *class_type TSRMLS_DC) {
340340
#endif
341341
}
342342

343-
/* Helper to retrieve the redisCluster object from the zend_object member */
344-
static redisCluster *getClusterObject(zend_object *object) {
345-
#if (PHP_MAJOR_VERSION < 7)
346-
return (redisCluster*)object;
347-
#else
348-
return (redisCluster*)((char*)(object) - XtOffsetOf(redisCluster, std));
349-
#endif
350-
}
351-
352343
/* Free redisCluster context */
353344
void
354345
#if (PHP_MAJOR_VERSION < 7)
355-
free_cluster_context(void *object TSRMLS_DC)
346+
free_cluster_context(void *object TSRMLS_DC) {
347+
redisCluster *cluster = (redisCluster*)object;
356348
#else
357-
free_cluster_context(zend_object *object)
349+
free_cluster_context(zend_object *object) {
350+
redisCluster *cluster = (redisCluster*)((char*)(object) - XtOffsetOf(redisCluster, std));
358351
#endif
359-
{
360-
redisCluster *cluster = getClusterObject(object);
361-
362352
// Free any allocated prefix, as well as the struct
363353
if(cluster->flags->prefix) efree(cluster->flags->prefix);
364354
efree(cluster->flags);
@@ -1949,6 +1939,7 @@ static void cluster_eval_cmd(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c,
19491939

19501940
/* validate that this key maps to the same node */
19511941
if(node && c->master[slot] != node) {
1942+
if (key_free) efree(key);
19521943
php_error_docref(NULL TSRMLS_CC, E_WARNING,
19531944
"Keys appear to map to different nodes");
19541945
RETURN_FALSE;
@@ -1980,7 +1971,7 @@ static void cluster_eval_cmd(INTERNAL_FUNCTION_PARAMETERS, redisCluster *c,
19801971
} else {
19811972
void *ctx = NULL;
19821973
CLUSTER_ENQUEUE_RESPONSE(c, slot, cluster_variant_resp, ctx);
1983-
RETURN_ZVAL(getThis(), 1, 0);
1974+
RETVAL_ZVAL(getThis(), 1, 0);
19841975
}
19851976

19861977
efree(cmdstr.c);

0 commit comments

Comments
 (0)