Zandronum Chat @ irc.zandronum.com
#zandronum
Get the latest version: 3.0
Source Code

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0003801Doomseeker[All Projects] Cleanuppublic2020-06-07 01:312020-06-17 08:24
ReporterWubTheCaptain 
Assigned ToWubTheCaptain 
PrioritynoneSeveritytweakReproducibilityalways
StatusresolvedResolutionsuspended 
PlatformOSOS Version
Product Version1.3.1 
Target VersionFixed in Version 
Summary0003801: new/delete used instead of std::unique_ptr/std::make_unique
DescriptionI tried to write a coherent description here, but I couldn't?

std::unique_ptr seems to be a better practice, instead of new/delete. Since C++11. Doomseeker (and Wadseeker) uses C++98 style new/delete.
And std::make_unique seems even better. Since C++14.

Let's modernize?
Steps To Reproduce
$ grep -r 'new ' src/ | wc -l
586
$ grep -r 'new\[\]' src/ | wc -l
0
$ grep -r 'delete\[\]' src/ | wc -l
8
$ grep -r 'delete ' src/ | wc -l
180
$ grep -r 'unique_ptr' src/ | wc -l
0
Additional Informationhttps://en.cppreference.com/w/cpp/memory/unique_ptr [^]
https://en.cppreference.com/w/cpp/memory/unique_ptr/make_unique [^]
https://isocpp.org/wiki/faq/freestore-mgmt [^]
https://clang.llvm.org/extra/clang-tidy/checks/modernize-make-unique.html [^]
Attached Files

- Relationships
child of 0003803confirmed C++11 support 
child of 0003804acknowledged C++14 support 

-  Notes
User avatar (0021376)
Pol M (developer)
2020-06-07 19:25

While this is a good idea, libraries shouldn't be touched. Also, while smart pointers will work, you could look for alternatives in each case. For instance:

diff --git a/src/wadseeker/zip/unarchive.cpp b/src/wadseeker/zip/unarchive.cpp
index 55f0a04a..9aeff22a 100644
--- a/src/wadseeker/zip/unarchive.cpp
+++ b/src/wadseeker/zip/unarchive.cpp
@@ -62,9 +62,8 @@ public:
                        position = bufferedData.size();
                        stream->seek(bufferedData.size());
                        QIODevice::seek(bufferedData.size());
- char *tmp = new char[neededDataSize];
- read(tmp, neededDataSize);
- delete[] tmp;
+ QVector<char> tmp(neededDataSize);
+ read(tmp.data(), neededDataSize);
                }
                else
                {
User avatar (0021465)
WubTheCaptain (developer)
2020-06-16 14:22

Should we use std::unique_ptr or Qt's QScopedPointer?
Mumble decided to go with STL pointers.https://github.com/mumble-voip/mumble/issues/3937 [^]
User avatar (0021466)
Pol M (developer)
2020-06-16 23:23

Since we are already using QScopedPointer, we should stick to that :)

Issue Community Support
This issue is already marked as resolved.
If you feel that is not the case, please reopen it and explain why.
Supporters: No one explicitly supports this issue yet.
Opponents: No one explicitly opposes this issue yet.

- Issue History
Date Modified Username Field Change
2020-06-07 01:31 WubTheCaptain New Issue
2020-06-07 02:26 WubTheCaptain Steps to Reproduce Updated View Revisions
2020-06-07 02:29 WubTheCaptain Relationship added child of 0003803
2020-06-07 02:32 WubTheCaptain Relationship added child of 0003804
2020-06-07 19:25 Pol M Note Added: 0021376
2020-06-07 19:25 Pol M Assigned To => Pol M
2020-06-07 19:25 Pol M Status new => confirmed
2020-06-07 19:40 Pol M Assigned To Pol M =>
2020-06-16 14:22 WubTheCaptain Note Added: 0021465
2020-06-16 14:22 WubTheCaptain Status confirmed => acknowledged
2020-06-16 23:23 Pol M Note Added: 0021466
2020-06-17 08:24 WubTheCaptain Status acknowledged => resolved
2020-06-17 08:24 WubTheCaptain Resolution open => suspended
2020-06-17 08:24 WubTheCaptain Assigned To => WubTheCaptain






Questions or other issues? Contact Us.

Links


Copyright © 2000 - 2020 MantisBT Team
Powered by Mantis Bugtracker