diff options
author | DDuarte <dnpd.dd@gmail.com> | 2014-07-25 14:04:39 +0100 |
---|---|---|
committer | DDuarte <dnpd.dd@gmail.com> | 2014-07-25 14:04:39 +0100 |
commit | baf99223505416d9ba011bd5e8485fa68fbf755e (patch) | |
tree | db65509926175733a62e09a924194336b12c225d | |
parent | 8e385ca6d9ca1f03e2b86885edc2b5d27b6ccddd (diff) |
Tools/mmaps: Fix a possible mem leak and a compile warning
-rw-r--r-- | src/tools/mmaps_generator/MapBuilder.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/tools/mmaps_generator/MapBuilder.cpp b/src/tools/mmaps_generator/MapBuilder.cpp index a29502535e6..94b5f3607cf 100644 --- a/src/tools/mmaps_generator/MapBuilder.cpp +++ b/src/tools/mmaps_generator/MapBuilder.cpp @@ -171,13 +171,16 @@ namespace MMAP { while (1) { - uint32* mapId; + uint32* mapId = nullptr; _queue.WaitAndPop(mapId); if (_cancelationToken) return; + if (!mapId) // shouldn't happen? + continue; + buildMap(*mapId); delete mapId; @@ -186,7 +189,7 @@ namespace MMAP void MapBuilder::buildAllMaps(int threads) { - for (size_t i = 0; i < threads; ++i) + for (int i = 0; i < threads; ++i) { _workerThreads.push_back(std::thread(&MapBuilder::WorkerThread, this)); } @@ -198,13 +201,13 @@ namespace MMAP for (TileList::iterator it = m_tiles.begin(); it != m_tiles.end(); ++it) { - uint32* mapID = new uint32(it->m_mapId); - if (!shouldSkipMap(*mapID)) + uint32 mapId = it->m_mapId; + if (!shouldSkipMap(mapId)) { if (threads > 0) - _queue.Push(mapID); + _queue.Push(new uint32(mapId)); else - buildMap(*mapID); + buildMap(mapId); } } |