Commit dcc2da10 authored by rubidium's avatar rubidium
Browse files

(svn r26609) -Fix: compile warnings on MSVC for 32 bits builds due to...

(svn r26609) -Fix: compile warnings on MSVC for 32 bits builds due to assigning values to variables with smaller integer size
parent 64d6adb0
......@@ -537,7 +537,7 @@ SQFunctionProto *SQFuncState::BuildProto()
for(SQUnsignedInteger no = 0; no < _lineinfos.size(); no++) f->_lineinfos[no] = _lineinfos[no];
for(SQUnsignedInteger no = 0; no < _defaultparams.size(); no++) f->_defaultparams[no] = _defaultparams[no];
memcpy(f->_instructions,&_instructions[0],_instructions.size()*sizeof(SQInstruction));
memcpy(f->_instructions,&_instructions[0],(size_t)_instructions.size()*sizeof(SQInstruction));
f->_varparams = _varparams;
......
......@@ -2,8 +2,8 @@
see copyright notice in squirrel.h
*/
#include "sqpcheader.h"
void *sq_vm_malloc(SQUnsignedInteger size){ return malloc(size); }
void *sq_vm_malloc(SQUnsignedInteger size){ return malloc((size_t)size); }
void *sq_vm_realloc(void *p, SQUnsignedInteger oldsize, SQUnsignedInteger size){ return realloc(p, size); }
void *sq_vm_realloc(void *p, SQUnsignedInteger oldsize, SQUnsignedInteger size){ return realloc(p, (size_t)size); }
void sq_vm_free(void *p, SQUnsignedInteger size){ free(p); }
......@@ -507,26 +507,26 @@ void SQStringTable::AllocNodes(SQInteger size)
{
_numofslots = size;
_strings = (SQString**)SQ_MALLOC(sizeof(SQString*)*_numofslots);
memset(_strings,0,sizeof(SQString*)*_numofslots);
memset(_strings,0,sizeof(SQString*)*(size_t)_numofslots);
}
SQString *SQStringTable::Add(const SQChar *news,SQInteger len)
{
if(len<0)
len = (SQInteger)scstrlen(news);
SQHash h = ::_hashstr(news,len)&(_numofslots-1);
SQHash h = ::_hashstr(news,(size_t)len)&(_numofslots-1);
SQString *s;
for (s = _strings[h]; s; s = s->_next){
if(s->_len == len && (!memcmp(news,s->_val,rsl(len))))
if(s->_len == len && (!memcmp(news,s->_val,(size_t)rsl(len))))
return s; //found
}
SQString *t=(SQString *)SQ_MALLOC(rsl(len)+sizeof(SQString));
new (t) SQString;
memcpy(t->_val,news,rsl(len));
memcpy(t->_val,news,(size_t)rsl(len));
t->_val[len] = _SC('\0');
t->_len = len;
t->_hash = ::_hashstr(news,len);
t->_hash = ::_hashstr(news,(size_t)len);
t->_next = _strings[h];
_strings[h] = t;
_slotused++;
......
......@@ -41,7 +41,7 @@ public:
size_t allocated_size = _allocated * sizeof(T);
_allocated = 0;
for(SQUnsignedInteger i = 0; i < _size; i++)
for(size_t i = 0; i < _size; i++)
_vals[i].~T();
SQ_FREE(_vals, allocated_size);
}
......@@ -61,7 +61,7 @@ public:
for(SQUnsignedInteger i = newsize; i < _size; i++) {
_vals[i].~T();
}
_size = newsize;
_size = (size_t)newsize;
}
}
void shrinktofit() { if(_size > 4) { _realloc(_size); } }
......@@ -90,7 +90,7 @@ public:
{
_vals[idx].~T();
if(idx < (_size - 1)) {
memmove(&_vals[idx], &_vals[idx+1], sizeof(T) * (_size - idx - 1));
memmove(&_vals[idx], &_vals[idx+1], sizeof(T) * (_size - (size_t)idx - 1));
}
_size--;
}
......@@ -103,10 +103,10 @@ private:
{
newsize = (newsize > 0)?newsize:4;
_vals = (T*)SQ_REALLOC(_vals, _allocated * sizeof(T), newsize * sizeof(T));
_allocated = newsize;
_allocated = (size_t)newsize;
}
SQUnsignedInteger _size;
SQUnsignedInteger _allocated;
size_t _size;
size_t _allocated;
};
#endif //_SQUTILS_H_
......@@ -289,8 +289,8 @@ bool SQVM::StringCat(const SQObjectPtr &str,const SQObjectPtr &obj,SQObjectPtr &
ToString(obj, b);
SQInteger l = _string(a)->_len , ol = _string(b)->_len;
SQChar *s = _sp(rsl(l + ol + 1));
memcpy(s, _stringval(a), rsl(l));
memcpy(s + l, _stringval(b), rsl(ol));
memcpy(s, _stringval(a), (size_t)rsl(l));
memcpy(s + l, _stringval(b), (size_t)rsl(ol));
dest = SQString::Create(_ss(this), _spval, l + ol);
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment