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

directly use the return value of statsrelay_list_expand #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/hashring.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ bool hashring_add(hashring_t ring, const char *line) {
}

// grow the list
if (statsrelay_list_expand(ring->backends) == NULL) {
void **new_obj = statsrelay_list_expand(ring->backends);
if (new_obj == NULL) {
stats_error_log("hashring: failed to expand list");
ring->dealloc(obj);
goto add_err;
}

ring->backends->data[ring->backends->size - 1] = obj;
*new_obj = obj;
return true;

add_err:
Expand Down
2 changes: 1 addition & 1 deletion src/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ list_t statsrelay_list_new() {
return list;
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ list_t statsrelay_list_new();

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

// deallocate the list
void statsrelay_list_destroy(list_t list);
Expand Down
5 changes: 3 additions & 2 deletions src/yaml_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,12 @@ struct config* parse_config(FILE *input) {
goto parse_err;
}
} else {
if (statsrelay_list_expand(protoc->ring) == NULL) {
char **data_ptr = (char **) statsrelay_list_expand(protoc->ring);
if (data_ptr == NULL) {
stats_error_log("unable to expand list");
goto parse_err;
}
if ((protoc->ring->data[protoc->ring->size - 1] = strdup(strval)) == NULL) {
if ((*data_ptr = strdup(strval)) == NULL) {
stats_error_log("failed to copy string");
goto parse_err;
}
Expand Down