texcache.cpp: Silence some compiler warnings.

This commit is contained in:
rogerman 2016-12-13 11:36:06 -08:00
parent 0628cb5756
commit ce4f61eaf6
1 changed files with 18 additions and 18 deletions

View File

@ -69,18 +69,18 @@ public:
//this MemSpan shall be considered the first argument to a standard memcmp //this MemSpan shall be considered the first argument to a standard memcmp
//the length shall be as specified in this MemSpan, unless you specify otherwise //the length shall be as specified in this MemSpan, unless you specify otherwise
int memcmp(void* buf2, int size=-1) int memcmp(void* buf2, int cmpSize=-1)
{ {
if(size==-1) size = this->size; if(cmpSize==-1) cmpSize = this->size;
size = min(this->size,size); cmpSize = min(this->size,cmpSize);
for(int i=0;i<numItems;i++) for(int i=0;i<numItems;i++)
{ {
Item &item = items[i]; Item &item = items[i];
int todo = min((int)item.len,size); int todo = min((int)item.len,cmpSize);
size -= todo; cmpSize -= todo;
int temp = ::memcmp(item.ptr,((u8*)buf2)+item.ofs,todo); int temp = ::memcmp(item.ptr,((u8*)buf2)+item.ofs,todo);
if(temp) return temp; if(temp) return temp;
if(size == 0) break; if(cmpSize == 0) break;
} }
return 0; return 0;
} }
@ -89,21 +89,21 @@ public:
//dumps the memspan to the specified buffer //dumps the memspan to the specified buffer
//you may set size to limit the size to be copied //you may set size to limit the size to be copied
int dump(void* buf, int size=-1) const int dump(void* buf, int dumpSize=-1) const
{ {
if(size==-1) size = this->size; if(dumpSize==-1) dumpSize = this->size;
size = min(this->size,size); dumpSize = min(this->size,dumpSize);
u8* bufptr = (u8*)buf; u8* bufptr = (u8*)buf;
int done = 0; int done = 0;
for(int i=0;i<numItems;i++) for(int i=0;i<numItems;i++)
{ {
Item item = items[i]; Item item = items[i];
int todo = min((int)item.len,size); int todo = min((int)item.len,dumpSize);
size -= todo; dumpSize -= todo;
done += todo; done += todo;
memcpy(bufptr,item.ptr,todo); memcpy(bufptr,item.ptr,todo);
bufptr += todo; bufptr += todo;
if(size==0) return done; if(dumpSize==0) return done;
} }
return done; return done;
} }
@ -111,18 +111,18 @@ public:
// this function does the same than dump // this function does the same than dump
// but works for both little and big endian // but works for both little and big endian
// when buf is an u16 array // when buf is an u16 array
int dump16(void* buf, int size=-1) const int dump16(void* buf, int dumpSize=-1) const
{ {
if(size==-1) size = this->size; if(dumpSize==-1) dumpSize = this->size;
size = min(this->size,size); dumpSize = min(this->size,dumpSize);
u16* bufptr = (u16*)buf; u16* bufptr = (u16*)buf;
int done = 0; int done = 0;
for(int i=0;i<numItems;i++) for(int i=0;i<numItems;i++)
{ {
Item item = items[i]; Item item = items[i];
u8 * src = (u8 *) item.ptr; u8 * src = (u8 *) item.ptr;
int todo = min((int)item.len,size); int todo = min((int)item.len,dumpSize);
size -= todo; dumpSize -= todo;
done += todo; done += todo;
for(int j = 0;j < todo / 2;j++) for(int j = 0;j < todo / 2;j++)
{ {
@ -131,7 +131,7 @@ public:
tmp |= *(src++) << 8; tmp |= *(src++) << 8;
*bufptr++ = tmp; *bufptr++ = tmp;
} }
if(size==0) return done; if(dumpSize==0) return done;
} }
return done; return done;
} }