diff options
| author | 2024-04-14 08:14:34 +1000 | |
|---|---|---|
| committer | 2024-04-14 08:14:34 +1000 | |
| commit | 4c4bb3181b343f7a7e238ce6cea8fae30bada908 (patch) | |
| tree | 3c7291f51a43c16d7d8b82bed188a5395708eeca /src/tools | |
| parent | 4980f881393e86d4de39f32b33ff1a98cd3f8f49 (diff) | |
Fixed a few more class memory access warnings.
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/regrep.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/tools/regrep.cpp b/src/tools/regrep.cpp index 21254acfe3c..316ef805f5a 100644 --- a/src/tools/regrep.cpp +++ b/src/tools/regrep.cpp @@ -14,6 +14,7 @@ #include "osdcomm.h" +#include <algorithm> #include <cassert> #include <cctype> #include <cstdio> @@ -67,8 +68,8 @@ struct summary_file summary_file * next; char name[20]; char source[100]; - uint8_t status[MAX_COMPARES]; - uint8_t matchbitmap[MAX_COMPARES]; + uint8_t status[MAX_COMPARES]; + uint8_t matchbitmap[MAX_COMPARES]; std::string text[MAX_COMPARES]; }; @@ -290,7 +291,7 @@ int main(int argc, char *argv[]) static summary_file *get_file(const char *filename) { - summary_file *file; + summary_file *file = nullptr; /* use the first two characters as a lookup */ for (file = filehash[filename[0] & 0x7f][filename[1] & 0x7f]; file != nullptr; file = file->next) @@ -298,10 +299,14 @@ static summary_file *get_file(const char *filename) return file; /* didn't find one -- allocate */ - file = (summary_file *)malloc(sizeof(*file)); + file = new (std::nothrow) summary_file; if (file == nullptr) return nullptr; - memset(file, 0, sizeof(*file)); + file->next = nullptr; + std::fill(std::begin(file->name), std::end(file->name), '\0'); + std::fill(std::begin(file->source), std::end(file->source), '\0'); + std::fill(std::begin(file->status), std::end(file->status), 0); + std::fill(std::begin(file->matchbitmap), std::end(file->matchbitmap), 0); /* set the name so we find it in the future */ strcpy(file->name, filename); @@ -510,7 +515,7 @@ static int CLIB_DECL compare_file(const void *file0ptr, const void *file1ptr) into a single, sorted list -------------------------------------------------*/ -static summary_file *sort_file_list(void) +static summary_file *sort_file_list() { summary_file *listhead, **tailptr, *curfile, **filearray; int numfiles, filenum; |
