Skip to content

Commit

Permalink
lib: Remove useless memcpy() calls in node allocators
Browse files Browse the repository at this point in the history
Fairly ugly that we even have these tiny dynamic allocs here for copying
node trees, but at least now we don't have memcpy cluttering it as well.
  • Loading branch information
vkoskiv committed Apr 4, 2024
1 parent 37469d1 commit 469eaa6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/common/node_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static enum cr_math_op value_node_op(const cJSON *data) {

static struct cr_value_node *vn_alloc(struct cr_value_node d) {
struct cr_value_node *desc = calloc(1, sizeof(*desc));
memcpy(desc, &d, sizeof(*desc));
*desc = d;
return desc;
}

Expand Down Expand Up @@ -197,7 +197,7 @@ void cr_value_node_free(struct cr_value_node *d) {

static struct cr_color_node *cn_alloc(struct cr_color_node d) {
struct cr_color_node *desc = calloc(1, sizeof(*desc));
memcpy(desc, &d, sizeof(*desc));
*desc = d;
return desc;
}

Expand Down Expand Up @@ -497,7 +497,7 @@ void cr_color_node_free(struct cr_color_node *d) {

static struct cr_vector_node *vecn_alloc(struct cr_vector_node d) {
struct cr_vector_node *desc = calloc(1, sizeof(*desc));
memcpy(desc, &d, sizeof(*desc));
*desc = d;
return desc;
}

Expand Down Expand Up @@ -631,7 +631,7 @@ void cr_vector_node_free(struct cr_vector_node *d) {

static struct cr_shader_node *bn_alloc(struct cr_shader_node d) {
struct cr_shader_node *desc = calloc(1, sizeof(*desc));
memcpy(desc, &d, sizeof(*desc));
*desc = d;
return desc;
}

Expand Down

0 comments on commit 469eaa6

Please sign in to comment.