Skip to content

Commit

Permalink
Replace calloc with malloc
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeshingles committed Aug 29, 2024
1 parent 9bd14ee commit ebb875b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
args: [--fix=lf]
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: 'v18.1.6'
rev: 'v18.1.8'
hooks:
- id: clang-format
files: '\.(c|cc|cpp|h|hpp|cxx|hh|inc)$'
Expand Down
10 changes: 5 additions & 5 deletions input.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void read_phixs_data_table(std::fstream &phixsfile, const int nphixspoints_input

assert_always(globals::elements[element].ions[lowerion].levels[lowerlevel].phixstargets == nullptr);
globals::elements[element].ions[lowerion].levels[lowerlevel].phixstargets =
static_cast<PhotoionTarget *>(calloc(1, sizeof(PhotoionTarget)));
static_cast<PhotoionTarget *>(malloc(sizeof(PhotoionTarget)));
assert_always(globals::elements[element].ions[lowerion].levels[lowerlevel].phixstargets != nullptr);

if (single_level_top_ion && (upperion == get_nions(element) - 1)) {
Expand All @@ -127,7 +127,7 @@ void read_phixs_data_table(std::fstream &phixsfile, const int nphixspoints_input
*mem_usage_phixs += in_nphixstargets * sizeof(PhotoionTarget);

globals::elements[element].ions[lowerion].levels[lowerlevel].phixstargets =
static_cast<PhotoionTarget *>(calloc(in_nphixstargets, sizeof(PhotoionTarget)));
static_cast<PhotoionTarget *>(malloc(in_nphixstargets * sizeof(PhotoionTarget)));
assert_always(globals::elements[element].ions[lowerion].levels[lowerlevel].phixstargets != nullptr);

double probability_sum = 0.;
Expand All @@ -151,7 +151,7 @@ void read_phixs_data_table(std::fstream &phixsfile, const int nphixspoints_input
globals::elements[element].ions[lowerion].levels[lowerlevel].nphixstargets = 1;
*mem_usage_phixs += sizeof(PhotoionTarget);
globals::elements[element].ions[lowerion].levels[lowerlevel].phixstargets =
static_cast<PhotoionTarget *>(calloc(1, sizeof(PhotoionTarget)));
static_cast<PhotoionTarget *>(malloc(sizeof(PhotoionTarget)));
assert_always(globals::elements[element].ions[lowerion].levels[lowerlevel].phixstargets != nullptr);

for (int i = 0; i < in_nphixstargets; i++) {
Expand Down Expand Up @@ -181,7 +181,7 @@ void read_phixs_data_table(std::fstream &phixsfile, const int nphixspoints_input

*mem_usage_phixs += globals::NPHIXSPOINTS * sizeof(float);
globals::elements[element].ions[lowerion].levels[lowerlevel].photoion_xs =
static_cast<float *>(calloc(globals::NPHIXSPOINTS, sizeof(float)));
static_cast<float *>(malloc(globals::NPHIXSPOINTS * sizeof(float)));
assert_always(globals::elements[element].ions[lowerion].levels[lowerlevel].photoion_xs != nullptr);

if (phixs_file_version == 1) {
Expand Down Expand Up @@ -757,7 +757,7 @@ void read_atomicdata_files() {
globals::elements[element].uniqueionindexstart = uniqueionindex;

// Initialize the elements ionlist
globals::elements[element].ions = static_cast<Ion *>(calloc(nions, sizeof(Ion)));
globals::elements[element].ions = static_cast<Ion *>(malloc(nions * sizeof(Ion)));
assert_always(globals::elements[element].ions != nullptr);

// now read in data for all ions of the current element. before doing so initialize
Expand Down

0 comments on commit ebb875b

Please sign in to comment.