From d29b242674fbf89035c8908753496522edf8eaee Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 28 May 2014 16:33:10 +0200 Subject: Fixed a memory leak in cPrefabPiecePool. The pool pieces weren't freed upon pool destruction. --- src/Generating/PrefabPiecePool.cpp | 28 ++++++++++++++++++++++++++++ src/Generating/PrefabPiecePool.h | 7 ++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/Generating/PrefabPiecePool.cpp b/src/Generating/PrefabPiecePool.cpp index ed9340815..145474bcc 100644 --- a/src/Generating/PrefabPiecePool.cpp +++ b/src/Generating/PrefabPiecePool.cpp @@ -26,6 +26,34 @@ cPrefabPiecePool::cPrefabPiecePool( +cPrefabPiecePool::~cPrefabPiecePool() +{ + Clear(); +} + + + + + +void cPrefabPiecePool::Clear(void) +{ + m_PiecesByConnector.clear(); + for (cPieces::iterator itr = m_AllPieces.begin(), end = m_AllPieces.end(); itr != end; ++itr) + { + delete *itr; + } + m_AllPieces.clear(); + for (cPieces::iterator itr = m_StartingPieces.begin(), end = m_StartingPieces.end(); itr != end; ++itr) + { + delete *itr; + } + m_StartingPieces.clear(); +} + + + + + void cPrefabPiecePool::AddPieceDefs(const cPrefab::sDef * a_PieceDefs, size_t a_NumPieceDefs) { ASSERT(a_PieceDefs != NULL); diff --git a/src/Generating/PrefabPiecePool.h b/src/Generating/PrefabPiecePool.h index c6a5ad360..50ae63c0c 100644 --- a/src/Generating/PrefabPiecePool.h +++ b/src/Generating/PrefabPiecePool.h @@ -34,6 +34,12 @@ public: const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs ); + /** Destroys the pool, freeing all pieces. */ + ~cPrefabPiecePool(); + + /** Removes and frees all pieces from this pool. */ + void Clear(void); + /** Adds pieces from the specified definitions into m_AllPieces. Also adds the pieces into the m_PiecesByConnector map. May be called multiple times with different PieceDefs, will add all such pieces. */ @@ -44,7 +50,6 @@ public: May be called multiple times with different PieceDefs, will add all such pieces. */ void AddStartingPieceDefs(const cPrefab::sDef * a_StartingPieceDefs, size_t a_NumStartingPieceDefs); - protected: /** The type used to map a connector type to the list of pieces with that connector */ -- cgit v1.2.3 From 171e13de4f58cdc4f8a97cd8adfbfbfbcf1df615 Mon Sep 17 00:00:00 2001 From: worktycho Date: Wed, 28 May 2014 15:59:59 +0100 Subject: for compiliers other than msvc we need to tell lua that its building as a dll --- lib/lua/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/lua/CMakeLists.txt b/lib/lua/CMakeLists.txt index db112d557..6e5e0f565 100644 --- a/lib/lua/CMakeLists.txt +++ b/lib/lua/CMakeLists.txt @@ -20,6 +20,12 @@ endif() # Lua needs to be linked dynamically on Windows and statically on *nix, so that LuaRocks work if (WIN32) + + #for compiliers other than msvc we need to tell lua that its building as a dll + if (NOT MSVC) + add_flags_cxx(-DLUA_BUILD_AS_DLL=1) + endif() + add_library(lua SHARED ${SOURCE}) set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/MCServer) -- cgit v1.2.3 From 1cf426d881e1ea3dbfae5ebae701e02cd41c95a0 Mon Sep 17 00:00:00 2001 From: worktycho Date: Wed, 28 May 2014 20:39:47 +0100 Subject: FreeBSD requires __POSIX_VISIBLE macro to be defined --- lib/sqlite/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/sqlite/CMakeLists.txt b/lib/sqlite/CMakeLists.txt index 0815127ef..d3bba6606 100644 --- a/lib/sqlite/CMakeLists.txt +++ b/lib/sqlite/CMakeLists.txt @@ -17,6 +17,10 @@ if (WIN32) source_group("Sources" FILES ${SOURCE}) endif() +# FreeBSD requires us to define this to get POSIX 2001 standard +if (SYSTEM_NAME STREQUAL "FreeBSD")) + add_flags_cxx(-D__POSIX_VISIBLE=200112) +endif() add_library(sqlite ${SOURCE}) -- cgit v1.2.3 From a2b741d904d55915fe041ff17d2ffadc7bf8221c Mon Sep 17 00:00:00 2001 From: worktycho Date: Wed, 28 May 2014 20:41:34 +0100 Subject: derp --- lib/sqlite/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sqlite/CMakeLists.txt b/lib/sqlite/CMakeLists.txt index d3bba6606..da16ce411 100644 --- a/lib/sqlite/CMakeLists.txt +++ b/lib/sqlite/CMakeLists.txt @@ -18,7 +18,7 @@ if (WIN32) endif() # FreeBSD requires us to define this to get POSIX 2001 standard -if (SYSTEM_NAME STREQUAL "FreeBSD")) +if (SYSTEM_NAME STREQUAL "FreeBSD") add_flags_cxx(-D__POSIX_VISIBLE=200112) endif() -- cgit v1.2.3 From 444cce1269b3efc3370358b389c4ebdfe1f2e5b2 Mon Sep 17 00:00:00 2001 From: worktycho Date: Wed, 28 May 2014 21:39:28 +0100 Subject: Cmake system name not System name --- lib/sqlite/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sqlite/CMakeLists.txt b/lib/sqlite/CMakeLists.txt index da16ce411..9add2280b 100644 --- a/lib/sqlite/CMakeLists.txt +++ b/lib/sqlite/CMakeLists.txt @@ -18,7 +18,7 @@ if (WIN32) endif() # FreeBSD requires us to define this to get POSIX 2001 standard -if (SYSTEM_NAME STREQUAL "FreeBSD") +if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") add_flags_cxx(-D__POSIX_VISIBLE=200112) endif() -- cgit v1.2.3