diff --git a/hircluster.c b/hircluster.c index 403be41..55aad0a 100644 --- a/hircluster.c +++ b/hircluster.c @@ -2564,11 +2564,12 @@ static int command_pre_fragment(redisClusterContext *cc, struct cmd *command, key_count = hiarray_n(command->keys); - sub_commands = hi_zalloc(REDIS_CLUSTER_SLOTS * sizeof(*sub_commands)); + sub_commands = hi_malloc(REDIS_CLUSTER_SLOTS * sizeof(*sub_commands)); if (sub_commands == NULL) { __redisClusterSetError(cc, REDIS_ERR_OOM, "Out of memory"); goto done; } + memset(sub_commands, 0, REDIS_CLUSTER_SLOTS * sizeof(*sub_commands)); command->frag_seq = hi_malloc(key_count * sizeof(*command->frag_seq)); if (command->frag_seq == NULL) { @@ -2662,12 +2663,14 @@ static int command_pre_fragment(redisClusterContext *cc, struct cmd *command, sub_command->clen += 13 + num_str_len; sub_command->cmd = - hi_zalloc(sub_command->clen * sizeof(*sub_command->cmd)); + hi_malloc(sub_command->clen * sizeof(*sub_command->cmd)); if (sub_command->cmd == NULL) { __redisClusterSetError(cc, REDIS_ERR_OOM, "Out of memory"); slot_num = -1; goto done; } + memset(sub_command->cmd, 0, + sub_command->clen * sizeof(*sub_command->cmd)); sub_command->cmd[idx++] = '*'; memcpy(sub_command->cmd + idx, num_str, num_str_len); @@ -2704,12 +2707,14 @@ static int command_pre_fragment(redisClusterContext *cc, struct cmd *command, sub_command->clen += 12 + num_str_len; sub_command->cmd = - hi_zalloc(sub_command->clen * sizeof(*sub_command->cmd)); + hi_malloc(sub_command->clen * sizeof(*sub_command->cmd)); if (sub_command->cmd == NULL) { __redisClusterSetError(cc, REDIS_ERR_OOM, "Out of memory"); slot_num = -1; goto done; } + memset(sub_command->cmd, 0, + sub_command->clen * sizeof(*sub_command->cmd)); sub_command->cmd[idx++] = '*'; memcpy(sub_command->cmd + idx, num_str, num_str_len); @@ -2746,12 +2751,14 @@ static int command_pre_fragment(redisClusterContext *cc, struct cmd *command, sub_command->clen += 15 + num_str_len; sub_command->cmd = - hi_zalloc(sub_command->clen * sizeof(*sub_command->cmd)); + hi_malloc(sub_command->clen * sizeof(*sub_command->cmd)); if (sub_command->cmd == NULL) { __redisClusterSetError(cc, REDIS_ERR_OOM, "Out of memory"); slot_num = -1; goto done; } + memset(sub_command->cmd, 0, + sub_command->clen * sizeof(*sub_command->cmd)); sub_command->cmd[idx++] = '*'; memcpy(sub_command->cmd + idx, num_str, num_str_len); @@ -2790,12 +2797,14 @@ static int command_pre_fragment(redisClusterContext *cc, struct cmd *command, sub_command->clen += 13 + num_str_len; sub_command->cmd = - hi_zalloc(sub_command->clen * sizeof(*sub_command->cmd)); + hi_malloc(sub_command->clen * sizeof(*sub_command->cmd)); if (sub_command->cmd == NULL) { __redisClusterSetError(cc, REDIS_ERR_OOM, "Out of memory"); slot_num = -1; goto done; } + memset(sub_command->cmd, 0, + sub_command->clen * sizeof(*sub_command->cmd)); sub_command->cmd[idx++] = '*'; memcpy(sub_command->cmd + idx, num_str, num_str_len); diff --git a/hiutil.c b/hiutil.c index fd85cfb..fae6f6f 100644 --- a/hiutil.c +++ b/hiutil.c @@ -230,17 +230,6 @@ int _uint_len(uint32_t num) { return n; } -void *_hi_zalloc(size_t size) { - void *p; - - p = hi_malloc(size); - if (p != NULL) { - memset(p, 0, size); - } - - return p; -} - void hi_stacktrace(int skip_count) { if (skip_count > 0) { } diff --git a/hiutil.h b/hiutil.h index 6c3f0e5..c4ba6f4 100644 --- a/hiutil.h +++ b/hiutil.h @@ -153,13 +153,6 @@ int hi_valid_port(int n); int _uint_len(uint32_t num); -/* - * Memory allocation wrapper. - */ -#define hi_zalloc(_s) _hi_zalloc((size_t)(_s)) - -void *_hi_zalloc(size_t size); - #ifndef WIN32 /* * Wrappers to send or receive n byte message on a blocking