8000 refactoring · jrtkcoder/phpredis@88d870e · GitHub
[go: up one dir, main page]

Skip to content

Commit 88d870e

Browse files
committed
refactoring
redis_sock_get and redis_array_get return pointer to RedisSock/RedisArray structure instead of assign by pointer pointer
1 parent 8fa85af commit 88d870e

File tree

4 files changed

+89
-92
lines changed

4 files changed

+89
-92
lines changed

common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ typedef enum _PUBSUB_TYPE {
576576
* function is redis_<cmdname>_cmd */
577577
#define REDIS_PROCESS_CMD(cmdname, resp_func) \
578578
RedisSock *redis_sock; char *cmd; int cmd_len; void *ctx=NULL; \
579-
if(redis_sock_get(getThis(), &redis_sock TSRMLS_CC, 0)<0 || \
579+
if ((redis_sock = redis_sock_get(getThis() TSRMLS_CC, 0)) == NULL || \
580580
redis_##cmdname##_cmd(INTERNAL_FUNCTION_PARAM_PASSTHRU,redis_sock, \
581581
&cmd, &cmd_len, NULL, &ctx)==FAILURE) { \
582582
RETURN_FALSE; \
@@ -591,7 +591,7 @@ typedef enum _PUBSUB_TYPE {
591591
* and keyword which is passed to us*/
592592
#define REDIS_PROCESS_KW_CMD(kw, cmdfunc, resp_func) \
593593
RedisSock *redis_sock; char *cmd; int cmd_len; void *ctx=NULL; \
594-
if(redis_sock_get(getThis(), &redis_sock TSRMLS_CC, 0)<0 || \
594+
if ((redis_sock = redis_sock_get(getThis() TSRMLS_CC, 0)) == NULL || \
595595
cmdfunc(INTERNAL_FUNCTION_PARAM_PASSTHRU, redis_sock, kw, &cmd, \
596596
&cmd_len, NULL, &ctx)==FAILURE) { \
597597
RETURN_FALSE; \

library.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ PHP_REDIS_API int redis_unsubscribe_response(INTERNAL_FUNCTION_PARAMETERS,
5959
PHP_REDIS_API int redis_sock_write(RedisSock *redis_sock, char *cmd, size_t sz TSRMLS_DC);
6060
PHP_REDIS_API void redis_stream_close(RedisSock *redis_sock TSRMLS_DC);
6161
PHP_REDIS_API int redis_check_eof(RedisSock *redis_sock, int no_throw TSRMLS_DC);
62-
PHP_REDIS_API int redis_sock_get(zval *id, RedisSock **redis_sock TSRMLS_DC, int nothrow);
62+
PHP_REDIS_API RedisSock *redis_sock_get(zval *id TSRMLS_DC, int nothrow);
6363
PHP_REDIS_API void redis_free_socket(RedisSock *redis_sock);
6464
PHP_REDIS_API void redis_send_discard(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock);
6565
PHP_REDIS_API void redis_sock_set_err(RedisSock *redis_sock, const char *msg, int msg_len);

0 commit comments

Comments
 (0)
0