Skip to content

Commit

Permalink
optimize calloc() args order
Browse files Browse the repository at this point in the history
  • Loading branch information
ruihongw committed Jul 3, 2020
1 parent 4af3e30 commit be463b0
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion doc/examples/urcu-flavors/bp.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int add_node(uint64_t v)
{
struct mynode *node;

node = calloc(sizeof(*node), 1);
node = calloc(1, sizeof(*node));
if (!node)
return -1;
node->value = v;
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/urcu-flavors/mb.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int add_node(uint64_t v)
{
struct mynode *node;

node = calloc(sizeof(*node), 1);
node = calloc(1, sizeof(*node));
if (!node)
return -1;
node->value = v;
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/urcu-flavors/membarrier.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int add_node(uint64_t v)
{
struct mynode *node;

node = calloc(sizeof(*node), 1);
node = calloc(1, sizeof(*node));
if (!node)
return -1;
node->value = v;
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/urcu-flavors/qsbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int add_node(uint64_t v)
{
struct mynode *node;

node = calloc(sizeof(*node), 1);
node = calloc(1, sizeof(*node));
if (!node)
return -1;
node->value = v;
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/urcu-flavors/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int add_node(uint64_t v)
{
struct mynode *node;

node = calloc(sizeof(*node), 1);
node = calloc(1, sizeof(*node));
if (!node)
return -1;
node->value = v;
Expand Down
4 changes: 2 additions & 2 deletions src/urcu-call-rcu-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ void rcu_barrier(void)
goto online;
}

completion = calloc(sizeof(*completion), 1);
completion = calloc(1, sizeof(*completion));
if (!completion)
urcu_die(errno);

Expand All @@ -908,7 +908,7 @@ void rcu_barrier(void)
cds_list_for_each_entry(crdp, &call_rcu_data_list, list) {
struct call_rcu_completion_work *work;

work = calloc(sizeof(*work), 1);
work = calloc(1, sizeof(*work));
if (!work)
urcu_die(errno);
work->completion = completion;
Expand Down
2 changes: 1 addition & 1 deletion src/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ void urcu_workqueue_queue_completion(struct urcu_workqueue *workqueue,
{
struct urcu_workqueue_completion_work *work;

work = calloc(sizeof(*work), 1);
work = calloc(1, sizeof(*work));
if (!work)
urcu_die(errno);
work->completion = completion;
Expand Down

0 comments on commit be463b0

Please sign in to comment.