# housekeeping + bugfix in file trace recorder
entity.cpp: fix indenting (was using space instead of tab) replace all instance of & operator=( with NO_COPY_CTOR trace: fix bug reported by michael: if trace file is huge, indices would keep on being recorded but data was cut off after a certain limit, leading to invalid pointers (into garbage data) This was SVN commit r4158.
This commit is contained in:
parent
7831f3cbe4
commit
90bfaf9c99
@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
@ -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<ScriptValue*> Params;
|
||||
|
||||
// squelch "unable to generate" warnings
|
||||
TSComponentFunction(const TSComponentFunction& rhs);
|
||||
const TSComponentFunction& operator=(const TSComponentFunction& rhs);
|
||||
NO_COPY_CTOR(TSComponentFunction);
|
||||
};
|
||||
|
||||
|
||||
|
@ -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<size_t> 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);
|
||||
|
@ -65,9 +65,7 @@ private:
|
||||
// Used to remember LogOnce messages
|
||||
std::set<std::string> m_LoggedOnce;
|
||||
|
||||
// squelch "unable to generate" warnings
|
||||
CLogger(const CLogger& rhs);
|
||||
const CLogger& operator=(const CLogger& rhs);
|
||||
NO_COPY_CTOR(CLogger);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -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;
|
||||
|
@ -31,9 +31,7 @@ template<class T> 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<class T> static int MemFunThunk(void* param, double UNUSED(time_left))
|
||||
@ -65,9 +63,7 @@ template<class T, class Arg> 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<class T, class Arg> static int MemFun1Thunk(void* param, double UNUSED(time_left))
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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<CStr, CStr_hash_compare> scriptsLoaded;
|
||||
|
||||
NO_COPY_CTOR(CEntityTemplate);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user