Skip to content

Commit 453030e

Browse files
committed
MISC: Address coverity findings
1 parent 781c63b commit 453030e

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

packages/seacas/applications/nem_spread/pe_input.C

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright(C) 1999-2020, 2023 National Technology & Engineering Solutions
2+
* Copyright(C) 1999-2020, 2023, 2025 National Technology & Engineering Solutions
33
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
44
* NTESS, the U.S. Government retains certain rights in this software.
55
*
@@ -434,8 +434,7 @@ int read_pexoII_info(NemSpread<T, INT> &spreader, const char *filename)
434434
cptr++;
435435

436436
/* allocate memory for to hold the values */
437-
PIO_Info.Dsk_List = reinterpret_cast<int *>(
438-
array_alloc(__FILE__, __LINE__, 1, PIO_Info.Dsk_List_Cnt, sizeof(int)));
437+
PIO_Info.Dsk_List.resize(PIO_Info.Dsk_List_Cnt);
439438
for (i = 0; i < (PIO_Info.Dsk_List_Cnt - 1); i++) {
440439
sscanf(cptr, "%d", &(PIO_Info.Dsk_List[i]));
441440
cptr = strtok(nullptr, ", \t;");

packages/seacas/applications/nem_spread/ps_pario_const.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright(C) 1999-2020, 2022, 2023, 2024 National Technology & Engineering Solutions
2+
* Copyright(C) 1999-2020, 2022, 2023, 2024, 2025 National Technology & Engineering Solutions
33
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
44
* NTESS, the U.S. Government retains certain rights in this software.
55
*
@@ -25,7 +25,7 @@ struct Parallel_IO
2525
{
2626
int Dsk_List_Cnt{};
2727

28-
int *Dsk_List{nullptr};
28+
std::vector<int> Dsk_List{};
2929
int **RDsk_List{nullptr};
3030

3131
int Num_Dsk_Ctrlrs{}; /* The number of disk controllers. */

packages/seacas/libraries/aprepro_lib/apr_exodus.cc

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ namespace {
3838
}
3939
}
4040

41-
void add_name(int exoid, ex_entity_type ent_type, int64_t id, char *name, std::string &names)
41+
void add_name(int exoid, ex_entity_type ent_type, int64_t id, std::vector<char> &name, std::string &names)
4242
{
4343
std::string str_name;
44-
ex_get_name(exoid, ent_type, id, name);
44+
ex_get_name(exoid, ent_type, id, name.data());
4545
if (name[0] == '\0') {
4646
str_name = entity_type_name(ent_type) + std::to_string(id);
4747
}
4848
else {
49-
str_name = name;
49+
str_name = name.data();
5050
}
5151

5252
if (names.length() > 0) {
@@ -313,7 +313,7 @@ namespace SEAMS {
313313
// -- 'ex_sideset_info'
314314
int max_name_length = ex_inquire_int(exoid, EX_INQ_DB_MAX_USED_NAME_LENGTH);
315315
ex_set_max_name_length(exoid, max_name_length);
316-
char *name = new char[max_name_length + 1];
316+
std::vector<char> name(max_name_length + 1);
317317
std::string str_name;
318318

319319
if (info.num_elem_blk > 0) {
@@ -366,7 +366,7 @@ namespace SEAMS {
366366
for (int64_t i = 0; i < info.num_assembly; i++) {
367367
ex_assembly assembly;
368368
assembly.id = ids[i];
369-
assembly.name = new char[max_name_length + 1];
369+
assembly.name = name.data();
370370
assembly.entity_list = nullptr;
371371

372372
ex_get_assembly(exoid, &assembly);
@@ -460,11 +460,11 @@ namespace SEAMS {
460460
if (num_global > 0) {
461461
std::string names;
462462
for (int i = 0; i < num_global; i++) {
463-
ex_get_variable_name(exoid, EX_GLOBAL, i + 1, name);
463+
ex_get_variable_name(exoid, EX_GLOBAL, i + 1, name.data());
464464
if (i > 0) {
465465
names += ",";
466466
}
467-
names += name;
467+
names += name.data();
468468
}
469469
aprepro->add_variable("ex_global_var_names", names);
470470

@@ -480,7 +480,6 @@ namespace SEAMS {
480480
aprepro->add_variable("ex_global_var_value", glo_array_data);
481481
}
482482

483-
delete[] name;
484483
ex_close(exoid);
485484
return "";
486485
}

0 commit comments

Comments
 (0)