Very tiny cleanup of ChunkFile.h.
Also changed the size parameter from DoVoid to size_t. As far as I know, that should never be negative. Also changed the the count parameter of DoArray to size_t, this also should never be negative. Got rid of some typecasts.
This commit is contained in:
parent
d6b53af115
commit
cf942450e0
|
@ -63,13 +63,13 @@ public:
|
|||
Mode GetMode() const {return mode;}
|
||||
u8 **GetPPtr() {return ptr;}
|
||||
|
||||
void DoVoid(void *data, int size)
|
||||
void DoVoid(void *data, size_t size)
|
||||
{
|
||||
switch (mode) {
|
||||
case MODE_READ: memcpy(data, *ptr, size); break;
|
||||
case MODE_WRITE: memcpy(*ptr, data, size); break;
|
||||
case MODE_MEASURE: break; // MODE_MEASURE - don't need to do anything
|
||||
case MODE_VERIFY: for(int i = 0; i < size; i++) _dbg_assert_msg_(COMMON, ((u8*)data)[i] == (*ptr)[i], "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); break;
|
||||
case MODE_VERIFY: for(size_t i = 0; i < size; i++) _dbg_assert_msg_(COMMON, ((u8*)data)[i] == (*ptr)[i], "Savestate verification failure: %d (0x%X) (at %p) != %d (0x%X) (at %p).\n", ((u8*)data)[i], ((u8*)data)[i], &((u8*)data)[i], (*ptr)[i], (*ptr)[i], &(*ptr)[i]); break;
|
||||
default: break; // throw an error?
|
||||
}
|
||||
(*ptr) += size;
|
||||
|
@ -78,7 +78,7 @@ public:
|
|||
template<class T>
|
||||
void Do(std::map<unsigned int, T> &x)
|
||||
{
|
||||
unsigned int number = (unsigned int)x.size();
|
||||
size_t number = x.size();
|
||||
Do(number);
|
||||
switch (mode) {
|
||||
case MODE_READ:
|
||||
|
@ -126,18 +126,17 @@ public:
|
|||
template<class T>
|
||||
void Do(std::deque<T> &x)
|
||||
{
|
||||
u32 deq_size = (u32)x.size();
|
||||
size_t deq_size = x.size();
|
||||
Do(deq_size);
|
||||
x.resize(deq_size);
|
||||
u32 i;
|
||||
for(i = 0; i < deq_size; i++)
|
||||
for(size_t i = 0; i < deq_size; i++)
|
||||
DoVoid(&x[i],sizeof(T));
|
||||
}
|
||||
|
||||
// Store strings.
|
||||
void Do(std::string &x)
|
||||
{
|
||||
int stringLen = (int)x.length() + 1;
|
||||
size_t stringLen = (x.length() + 1);
|
||||
Do(stringLen);
|
||||
|
||||
switch (mode) {
|
||||
|
@ -151,7 +150,7 @@ public:
|
|||
|
||||
void Do(std::wstring &x)
|
||||
{
|
||||
int stringLen = sizeof(wchar_t)*((int)x.length() + 1);
|
||||
size_t stringLen = sizeof(wchar_t)*(x.length() + 1);
|
||||
Do(stringLen);
|
||||
|
||||
switch (mode) {
|
||||
|
@ -164,7 +163,7 @@ public:
|
|||
}
|
||||
|
||||
template<class T>
|
||||
void DoArray(T *x, int count) {
|
||||
void DoArray(T *x, size_t count) {
|
||||
DoVoid((void *)x, sizeof(T) * count);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue