diff --git a/source/graphics/MapReader.cpp b/source/graphics/MapReader.cpp index 521ca94653..4080fedb56 100644 --- a/source/graphics/MapReader.cpp +++ b/source/graphics/MapReader.cpp @@ -282,9 +282,7 @@ private: int ReadEntities(XMBElement parent, double end_time); int ReadNonEntities(XMBElement parent, double end_time); - // squelch "unable to generate" warnings - CXMLReader(const CXMLReader& rhs); - const CXMLReader& operator=(const CXMLReader& rhs); + NO_COPY_CTOR(CXMLReader); }; diff --git a/source/i18n/TSComponent.h b/source/i18n/TSComponent.h index cdc1eb52db..aebee7df12 100644 --- a/source/i18n/TSComponent.h +++ b/source/i18n/TSComponent.h @@ -36,9 +36,7 @@ namespace I18n private: const StrImW String; - // squelch "unable to generate" warnings - TSComponentString(const TSComponentString& rhs); - const TSComponentString& operator=(const TSComponentString& rhs); + NO_COPY_CTOR(TSComponentString); }; @@ -69,9 +67,7 @@ namespace I18n const std::string Name; std::vector Params; - // squelch "unable to generate" warnings - TSComponentFunction(const TSComponentFunction& rhs); - const TSComponentFunction& operator=(const TSComponentFunction& rhs); + NO_COPY_CTOR(TSComponentFunction); }; diff --git a/source/lib/res/file/trace.cpp b/source/lib/res/file/trace.cpp index 3c6781f1f3..e7e60975d6 100644 --- a/source/lib/res/file/trace.cpp +++ b/source/lib/res/file/trace.cpp @@ -65,24 +65,25 @@ void trace_enable(bool want_enabled) } -static void trace_add(TraceOp op, const char* P_fn, size_t size, +static LibError trace_add(TraceOp op, const char* P_fn, size_t size, uint flags = 0, double timestamp = 0.0) { trace_init(); if(!trace_enabled) - return; + return INFO_OK; if(timestamp == 0.0) timestamp = get_time(); TraceEntry* t = (TraceEntry*)pool_alloc(&trace_pool, 0); if(!t) - return; + return ERR_LIMIT; // NOWARN t->timestamp = timestamp; t->atom_fn = file_make_unique_fn_copy(P_fn); t->size = size; t->op = op; t->flags = flags; + return INFO_OK; } static void trace_get_raw_ents(const TraceEntry*& ents, size_t& num_ents) @@ -125,6 +126,8 @@ static const uint MAX_RUNS = 100; static TraceRun runs[MAX_RUNS]; // note: the last entry may be one past number of actual entries. +// WARNING: due to misfeature in DelimiterAdder, indices are added twice. +// this is fixed in trace_get; just don't rely on run_start_indices.size()! static std::vector run_start_indices; class DelimiterAdder @@ -186,9 +189,12 @@ void trace_get(Trace* t) // run_start_indices.back() may be = num_ents (could happen if // a zero-length run gets written out); skip that to avoid // zero-length run here. + // also fixes DelimiterAdder misbehavior of adding 2 indices per run. if(last_start_idx == start_idx) continue; + debug_assert(start_idx < t->total_ents); + TraceRun& run = runs[t->num_runs++]; run.num_ents = last_start_idx - start_idx; run.ents = &ents[start_idx]; @@ -295,7 +301,14 @@ LibError trace_read_from_file(const char* trace_filename, Trace* t) } if(delim_adder(i, timestamp, P_path) != DelimiterAdder::SKIP_ADD) - trace_add(op, P_path, size, flags, timestamp); + { + LibError ret = trace_add(op, P_path, size, flags, timestamp); + // storage in trace pool exhausted. must abort to avoid later + // adding delimiters for items that weren't actually stored + // into the pool. + if(ret == ERR_LIMIT) + break; + } } fclose(f); diff --git a/source/ps/CLogger.h b/source/ps/CLogger.h index 7998253f01..c265eadd34 100644 --- a/source/ps/CLogger.h +++ b/source/ps/CLogger.h @@ -65,9 +65,7 @@ private: // Used to remember LogOnce messages std::set m_LoggedOnce; - // squelch "unable to generate" warnings - CLogger(const CLogger& rhs); - const CLogger& operator=(const CLogger& rhs); + NO_COPY_CTOR(CLogger); }; #endif diff --git a/source/ps/Game.h b/source/ps/Game.h index 08adfe3066..723842e278 100644 --- a/source/ps/Game.h +++ b/source/ps/Game.h @@ -101,9 +101,7 @@ public: private: PSRETURN RegisterInit(CGameAttributes* pAttribs); - // squelch "unable to generate" warnings - CGame(const CGame& rhs); - const CGame& operator=(const CGame& rhs); + NO_COPY_CTOR(CGame); }; extern CGame *g_Game; diff --git a/source/ps/LoaderThunks.h b/source/ps/LoaderThunks.h index cea63f9113..41fb9345a5 100644 --- a/source/ps/LoaderThunks.h +++ b/source/ps/LoaderThunks.h @@ -31,9 +31,7 @@ template struct MemFun_t MemFun_t(T* this__, int(T::*func_)(void)) : this_(this__), func(func_) {} - // squelch "unable to generate" warnings - MemFun_t(const MemFun_t& rhs); - const MemFun_t& operator=(const MemFun_t& rhs); + NO_COPY_CTOR(MemFun_t); }; template static int MemFunThunk(void* param, double UNUSED(time_left)) @@ -65,9 +63,7 @@ template struct MemFun1_t MemFun1_t(T* this__, int(T::*func_)(Arg), Arg arg_) : this_(this__), func(func_), arg(arg_) {} - // squelch "unable to generate" warnings - MemFun1_t(const MemFun1_t& rhs); - const MemFun1_t& operator=(const MemFun1_t& rhs); + NO_COPY_CTOR(MemFun1_t); }; template static int MemFun1Thunk(void* param, double UNUSED(time_left)) diff --git a/source/ps/ThreadUtil.h b/source/ps/ThreadUtil.h index 514e8e0933..1cad93c5a0 100644 --- a/source/ps/ThreadUtil.h +++ b/source/ps/ThreadUtil.h @@ -159,9 +159,7 @@ public: private: pthread_mutex_t &m_Mutex; - // squelch "unable to generate" warnings - CScopeLock(const CScopeLock& rhs); - const CScopeLock& operator=(const CScopeLock& rhs); + NO_COPY_CTOR(CScopeLock); }; // CLocker diff --git a/source/ps/World.h b/source/ps/World.h index 75946cb8c4..df27bc4af0 100644 --- a/source/ps/World.h +++ b/source/ps/World.h @@ -57,10 +57,7 @@ public: inline CTerritoryManager *GetTerritoryManager() { return m_TerritoryManager; } -private: - // squelch "unable to generate" warnings - CWorld(const CWorld& rhs); - const CWorld& operator=(const CWorld& rhs); + NO_COPY_CTOR(CWorld); }; // rationale: see definition. diff --git a/source/simulation/Entity.h b/source/simulation/Entity.h index c3938b796c..9532d4dc18 100644 --- a/source/simulation/Entity.h +++ b/source/simulation/Entity.h @@ -481,10 +481,7 @@ public: } static void ScriptingInit(); -private: - // squelch "unable to generate" warnings - CEntity(const CEntity& rhs); - const CEntity& operator=(const CEntity& rhs); + NO_COPY_CTOR(CEntity); }; // General entity globals diff --git a/source/simulation/EntityTemplate.h b/source/simulation/EntityTemplate.h index 900d2a6b6a..a233a1a433 100644 --- a/source/simulation/EntityTemplate.h +++ b/source/simulation/EntityTemplate.h @@ -161,11 +161,9 @@ public: static void ScriptingInit(); private: - // squelch "unable to generate" warnings - CEntityTemplate(const CEntityTemplate& rhs); - const CEntityTemplate& operator=(const CEntityTemplate& rhs); - static STL_HASH_SET scriptsLoaded; + + NO_COPY_CTOR(CEntityTemplate); }; #endif