Skip to content
This repository was archived by the owner on Feb 18, 2021. It is now read-only.

Commit 62c691b

Browse files
committed
directly use the return value of statsrelay_list_expand
1 parent 94cf1b6 commit 62c691b

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

src/hashring.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@ bool hashring_add(hashring_t ring, const char *line) {
6363
}
6464

6565
// grow the list
66-
if (statsrelay_list_expand(ring->backends) == NULL) {
66+
void **new_obj = statsrelay_list_expand(ring->backends);
67+
if (new_obj == NULL) {
6768
stats_error_log("hashring: failed to expand list");
6869
ring->dealloc(obj);
6970
goto add_err;
7071
}
7172

72-
ring->backends->data[ring->backends->size - 1] = obj;
73+
*new_obj = obj;
7374
return true;
7475

7576
add_err:

src/list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ list_t statsrelay_list_new() {
1414
return list;
1515
}
1616

17-
void* statsrelay_list_expand(list_t list) {
17+
void** statsrelay_list_expand(list_t list) {
1818
size_t index = list->size;
1919
list->size++;
2020

src/list.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ list_t statsrelay_list_new();
1616

1717
// get the address for a new item in the list, and ensure its size is
1818
// expanded
19-
void *statsrelay_list_expand(list_t list);
19+
void **statsrelay_list_expand(list_t list);
2020

2121
// deallocate the list
2222
void statsrelay_list_destroy(list_t list);

src/yaml_config.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,12 @@ struct config* parse_config(FILE *input) {
188188
goto parse_err;
189189
}
190190
} else {
191-
if (statsrelay_list_expand(protoc->ring) == NULL) {
191+
char **data_ptr = (char **) statsrelay_list_expand(protoc->ring);
192+
if (data_ptr == NULL) {
192193
stats_error_log("unable to expand list");
193194
goto parse_err;
194195
}
195-
if ((protoc->ring->data[protoc->ring->size - 1] = strdup(strval)) == NULL) {
196+
if ((*data_ptr = strdup(strval)) == NULL) {
196197
stats_error_log("failed to copy string");
197198
goto parse_err;
198199
}

0 commit comments

Comments
 (0)