Skip to content

Commit

Permalink
Correct argument order for calloc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerilk committed Nov 13, 2024
1 parent 1e00868 commit 22364ff
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/configuration_space_deserialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ _ccs_deserialize_bin_ccs_configuration_space_data(
data->num_forbidden_clauses))
return CCS_RESULT_SUCCESS;
mem = (uintptr_t)calloc(
1,
data->num_parameters * sizeof(ccs_parameter_t) +
data->num_parameters * sizeof(ccs_expression_t) +
data->num_forbidden_clauses * sizeof(ccs_expression_t),
1);
data->num_forbidden_clauses * sizeof(ccs_expression_t));
CCS_REFUTE(!mem, CCS_RESULT_ERROR_OUT_OF_MEMORY);

data->parameters = (ccs_parameter_t *)mem;
Expand Down
7 changes: 3 additions & 4 deletions src/distribution_space_deserialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ _ccs_deserialize_bin_ccs_distribution_space_data(
if (!(data->num_distributions))
return CCS_RESULT_SUCCESS;
mem = (uintptr_t)calloc(
data->num_distributions *
(sizeof(ccs_distribution_t) + sizeof(size_t)) +
data->num_parameters * sizeof(size_t),
1);
1, data->num_distributions * (sizeof(ccs_distribution_t) +
sizeof(size_t)) +
data->num_parameters * sizeof(size_t));
CCS_REFUTE(!mem, CCS_RESULT_ERROR_OUT_OF_MEMORY);

data->distributions = (ccs_distribution_t *)mem;
Expand Down
4 changes: 2 additions & 2 deletions src/objective_space_deserialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ _ccs_deserialize_bin_ccs_objective_space_data(
if (!(data->num_parameters + data->num_objectives))
return CCS_RESULT_SUCCESS;
mem = (uintptr_t)calloc(
1,
data->num_parameters * sizeof(ccs_parameter_t) +
data->num_objectives * (sizeof(ccs_expression_t) +
sizeof(ccs_objective_type_t)),
1);
sizeof(ccs_objective_type_t)));
CCS_REFUTE(!mem, CCS_RESULT_ERROR_OUT_OF_MEMORY);
data->parameters = (ccs_parameter_t *)mem;
mem += data->num_parameters * sizeof(ccs_parameter_t);
Expand Down
2 changes: 1 addition & 1 deletion src/tuner_deserialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ _ccs_deserialize_bin_ccs_random_tuner_data(
if (!(data->history_size + data->size_optima))
return CCS_RESULT_SUCCESS;
mem = (uintptr_t)calloc(
(data->history_size + data->size_optima),
data->history_size + data->size_optima,
sizeof(ccs_evaluation_t));
CCS_REFUTE(!mem, CCS_RESULT_ERROR_OUT_OF_MEMORY);

Expand Down
4 changes: 2 additions & 2 deletions src/tuner_user_defined.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ _ccs_serialize_bin_size_ccs_user_defined_tuner(
*cum_size += _ccs_serialize_bin_size_size(num_optima);
if (0 != history_size + num_optima) {
history = (ccs_evaluation_t *)calloc(
sizeof(ccs_evaluation_t), history_size + num_optima);
history_size + num_optima, sizeof(ccs_evaluation_t));
CCS_REFUTE(!history, CCS_RESULT_ERROR_OUT_OF_MEMORY);
optima = history + history_size;
if (history_size) {
Expand Down Expand Up @@ -119,7 +119,7 @@ _ccs_serialize_bin_ccs_user_defined_tuner(
CCS_VALIDATE(_ccs_serialize_bin_size(num_optima, buffer_size, buffer));
if (0 != history_size + num_optima) {
history = (ccs_evaluation_t *)calloc(
sizeof(ccs_evaluation_t), history_size + num_optima);
history_size + num_optima, sizeof(ccs_evaluation_t));
CCS_REFUTE(!history, CCS_RESULT_ERROR_OUT_OF_MEMORY);
optima = history + history_size;
if (history_size) {
Expand Down

0 comments on commit 22364ff

Please sign in to comment.