more const in format detection

BaseImporter::SearchFileHeaderForToken() expected a pointer to a non-const token list. This was probably an oversight, as nobody would realistically expect the function to change the list. Furthermore, it prevented token lists from being compiled to read-only memory, in some cases even causing the compiler to generate thread-safe initialization.

The list is now const and all callers declare their token lists static const, thus compiling them to read-only memory.
This commit is contained in:
Krishty
2021-09-11 23:23:05 +02:00
parent d34cd103f4
commit 5895c0c22c
26 changed files with 31 additions and 32 deletions

View File

@@ -130,8 +130,8 @@ bool DXFImporter::CanRead( const std::string& filename, IOSystem* pIOHandler, bo
}
if ( extension.empty() || checkSig ) {
const char *pTokens[] = { "SECTION", "HEADER", "ENDSEC", "BLOCKS" };
return BaseImporter::SearchFileHeaderForToken(pIOHandler, filename, pTokens, 4, 32 );
static const char * const pTokens[] = { "SECTION", "HEADER", "ENDSEC", "BLOCKS" };
return SearchFileHeaderForToken(pIOHandler, filename, pTokens, 4, 32 );
}
return false;