-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider modernizing the C++ code in wartool.cpp #398
Comments
Hi. For example speaking of But it just imho. Anyway every improvement will be appreciated. |
By the way, in case if you don't know - there is a discord channel. |
Cool, I did not know about the discord channel. Thanks for the response, it wasn't super clear if there was some coding guidelines I missed. I know there are a decent number of people and projects that prefer to write C with classes style C++. |
Reading through the code in wartool.cpp, I am noticing a lot of raw pointer manipulations,
malloc
s, andfree
s. Since the cmake file sets the C++ standard to C++17, it might make sense to modernize some of the code.As one example,
unsigned char* ExtractEntry(unsigned char* cp, size_t* lenp)
is used alot throughout the code, and if we were wanting to use something closer to idiomatic C++17 it would probably return astd::vector<unsigned char>
. Even if we were wanting to continue using pointers, the result of ExtractEntry seems to be used at most once, so changing it to astd::unique_ptr<unsigned char[]>
as the return value would probably make sense.There are of course other cases, but that function seems like a reasonable starting point since it is used so often. More broadly changing the IO functions from printfs and null terminated strings to
std::string
s and iostreams would probably make sense as well since there are a largish number of string manipulations I saw.Let me know if there is any interest in making changes like that, or if anyone has any other concerns or ideas about a change like that.
The text was updated successfully, but these errors were encountered: