uppsrc: Fixed many Win64 warnings

git-svn-id: svn://ultimatepp.org/upp/trunk@5821 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2013-02-18 09:30:12 +00:00
parent 9a984ac257
commit c459246cfd
7 changed files with 30 additions and 46 deletions

View file

@ -42,7 +42,7 @@ static void *SslRealloc(void *ptr, size_t size)
return NULL;
}
*newaptr++ = newalloc;
memcpy(newaptr, ptr, min<int>((int)(*aptr - sizeof(int64)), size));
memcpy(newaptr, ptr, min<int>((int)(*aptr - sizeof(int64)), (int)size));
UPP_SSL_alloc += newalloc - *aptr;
LLOG("UPP_SSL_REALLOC(" << ptr << ", " << (int64)size << ", alloc " << newalloc << ") -> "
<< FormatIntHex(newaptr) << ", total = " << UPP_SSL_alloc);

View file

@ -6,7 +6,7 @@ String SslBuffer::Get() const
{
if(IsEmpty())
return String::GetVoid();
return String(buf_mem->data, buf_mem->length);
return String(buf_mem->data, (int)buf_mem->length);
}
bool SslBuffer::Grow(int length)
@ -50,7 +50,7 @@ String SslStream::GetResult() const
BIO_get_mem_ptr(bio, &bm);
if(!bm)
return String::GetVoid();
return String(bm->data, bm->length);
return String(bm->data, (int)bm->length);
}
bool SslKey::Load(const String& data)

View file

@ -217,7 +217,7 @@ void SubpixelFiller::Render(int val, int len)
if(len > 6) {
int q = (3333333 - (v + 2 - begin)) % 3;
len -= q + 2;
int l = v + 2 + q - begin;
int l = int(v + 2 + q - begin);
RenderN(val, h, q + 4);
Write(l / 3);
l = len / 3;
@ -238,7 +238,7 @@ void SubpixelFiller::Render(int val, int len)
else {
if(val == 256)
if(!ss && color.a == 255) {
FillRGBA(t, color, e - t);
FillRGBA(t, color, int(e - t));
t = e;
}
else
@ -293,7 +293,7 @@ void SubpixelFiller::Write(int len)
void SubpixelFiller::End()
{
v[3] = v[4] = v[5] = 0;
Write((v + 3 - begin) / 3);
Write(int(v + 3 - begin) / 3);
}
void SpanFiller::Start(int minx, int maxx)
@ -415,7 +415,7 @@ void ClipFiller::Finish(ClippingLine& cl)
if(full)
cl.SetFull();
else
cl.Set(~buffer, t - ~buffer);
cl.Set(~buffer, int(t - ~buffer));
}
void MaskFillerFilter::Render(int val)

View file

@ -80,7 +80,7 @@ void BufferPainter::FinishMask()
if(c256) t = sSpan(t, 128, c256);
if(c0) t = sSpan(t, 0, c0);
cl[y].Clear();
cl[y].Set(~wb, t - ~wb);
cl[y].Set(~wb, int(t - ~wb));
}
ib = mask.Top();
mask.Drop();

View file

@ -153,7 +153,7 @@ bool PostgreSQLPerformScript(const String& txt, StatementExecutor& se, Gate2<int
else
stmt.Cat(*text++);
}
if(progress_canceled(text - txt.Begin(), txt.GetLength()))
if(progress_canceled(int(text - txt.Begin()), txt.GetLength()))
return false;
if(!se.Execute(stmt))
return false;
@ -447,8 +447,8 @@ void PostgreSQLConnection::SetParam(int i, const Value& r)
String raw = SqlRaw(r);
size_t rl;
unsigned char *s = PQescapeByteaConn(conn, (const byte *)~raw, raw.GetLength(), &rl);
p.Reserve(rl + 16);
p = "\'" + String(s, rl - 1) + "\'::bytea";
p.Reserve(int(rl + 16));
p = "\'" + String(s, int(rl - 1)) + "\'::bytea";
PQfreemem(s);
break;
}
@ -460,7 +460,7 @@ void PostgreSQLConnection::SetParam(int i, const Value& r)
char *q = b;
*q = '\'';
int *err = NULL;
int n = PQescapeStringConn(conn, q + 1, v, v.GetLength(), err);
int n = (int)PQescapeStringConn(conn, q + 1, v, v.GetLength(), err);
q[1 + n] = '\'';
b.SetCount(2 + n);
p = b;
@ -638,11 +638,11 @@ void PostgreSQLConnection::GetColumn(int i, Ref f) const
default: {
if(oid[i] == PGSQL_BYTEAOID) {
if(session.hex_blobs)
f.SetValue(ScanHexString(s, strlen(s)));
f.SetValue(ScanHexString(s, (int)strlen(s)));
else {
size_t len;
unsigned char *q = PQunescapeBytea((const unsigned char *)s, &len);
f.SetValue(String(q, len));
f.SetValue(String(q, (int)len));
PQfreemem(q);
}
}

View file

@ -191,8 +191,8 @@ public:
SqlS(const char *s, int pr) : text(s), priority(pr) {}
SqlS(const String& s, int pr) : text(s), priority(pr) {}
force_inline SqlS(const SqlS& a, const char *op, const SqlS& b, int pr, int prb) { Init(a, op, strlen(op), b, pr, prb); }
force_inline SqlS(const SqlS& a, const char *op, const SqlS& b, int pr) { Init(a, op, strlen(op), b, pr, pr); }
force_inline SqlS(const SqlS& a, const char *op, const SqlS& b, int pr, int prb) { Init(a, op, (int)strlen(op), b, pr, prb); }
force_inline SqlS(const SqlS& a, const char *op, const SqlS& b, int pr) { Init(a, op, (int)strlen(op), b, pr, pr); }
};
class SqlVal : public SqlS, Moveable<SqlVal> {

View file

@ -10,7 +10,7 @@ NAMESPACE_UPP
#define LOG_UPP_SSL_MALLOC 0
#if LOG_UPP_SSL_MALLOC
static int UPP_SSL_alloc = 0;
static size_t UPP_SSL_alloc = 0;
#endif
struct SSLInitCls {
@ -55,10 +55,9 @@ void SSLInitCls::AddThread()
void *SSLAlloc(size_t size)
{
size_t alloc = size + sizeof(int);
int *aptr = (int *)MemoryAllocSz(alloc);
if(!aptr)
{
size_t alloc = size + sizeof(size_t);
size_t *aptr = (size_t *)MemoryAllocSz(alloc);
if(!aptr) {
#if LOG_UPP_SSL_MALLOC
RLOG("UPP_SSL_MALLOC(" << (int)size << ", alloc " << alloc << ") -> failed, total = " << UPP_SSL_alloc);
#endif
@ -76,7 +75,7 @@ void SSLFree(void *ptr)
{
if(!ptr)
return;
int *aptr = (int *)ptr - 1;
size_t *aptr = (size_t *)ptr - 1;
#if LOG_UPP_SSL_MALLOC
UPP_SSL_alloc -= *aptr;
RLOG("UPP_SSL_FREE(" << ptr << ", alloc " << *aptr << "), total = " << UPP_SSL_alloc);
@ -88,16 +87,16 @@ void *SSLRealloc(void *ptr, size_t size)
{
if(!ptr)
return NULL;
int *aptr = (int *)ptr - 1;
if((int)(size + sizeof(int)) <= *aptr)
size_t *aptr = (size_t *)ptr - 1;
if(size + sizeof(size_t) <= *aptr)
{
#if LOG_UPP_SSL_MALLOC
RLOG("UPP_SSL_REALLOC(" << ptr << ", " << (int)size << ", alloc " << *aptr << ") -> keep same block");
#endif
return ptr;
}
size_t newalloc = size + sizeof(int);
int *newaptr = (int *)MemoryAllocSz(newalloc);
size_t newalloc = size + sizeof(size_t);
size_t *newaptr = (size_t *)MemoryAllocSz(newalloc);
if(!newaptr)
{
#if LOG_UPP_SSL_MALLOC
@ -106,7 +105,7 @@ void *SSLRealloc(void *ptr, size_t size)
return NULL;
}
*newaptr++ = newalloc;
memcpy(newaptr, ptr, min<int>(*aptr - sizeof(int), size));
memcpy(newaptr, ptr, min<size_t>(*aptr - sizeof(size_t), size));
#if LOG_UPP_SSL_MALLOC
UPP_SSL_alloc += newalloc - *aptr;
RLOG("UPP_SSL_REALLOC(" << ptr << ", " << (int)size << ", alloc " << newalloc << ") -> "
@ -116,21 +115,6 @@ void *SSLRealloc(void *ptr, size_t size)
return newaptr;
}
/*
void SSLInit()
{
static bool inited = false;
if(!inited)
{
inited = true;
Socket::Init();
CRYPTO_set_mem_functions(SSLAlloc, SSLRealloc, SSLFree);
SSL_load_error_strings();
SSL_library_init();
}
}
*/
String SSLGetLastError(int& code)
{
char errbuf[150];
@ -173,7 +157,7 @@ String SSLBuffer::Get() const
{
if(IsEmpty())
return String::GetVoid();
return String(buf_mem->data, buf_mem->length);
return String(buf_mem->data, (int)buf_mem->length);
}
bool SSLBuffer::Grow(int length)
@ -217,7 +201,7 @@ String SSLStream::GetResult() const
BIO_get_mem_ptr(bio, &bm);
if(!bm)
return String::GetVoid();
return String(bm->data, bm->length);
return String(bm->data, (int)bm->length);
}
bool SSLKey::Load(String data)
@ -491,7 +475,7 @@ bool SSLSocketData::Secure()
SetSSLError("OpenClient / SSL_new");
return false;
}
if(!SSL_set_fd(ssl, socket))
if(!SSL_set_fd(ssl, (int)socket))
{
SetSSLError("OpenClient / SSL_set_fd");
return false;
@ -515,7 +499,7 @@ bool SSLSocketData::OpenAccept(SOCKET conn, bool nodelay, bool blocking)
SetSSLError("Accept / SSL_new");
return false;
}
if(!SSL_set_fd(ssl, socket))
if(!SSL_set_fd(ssl, (int)socket))
{
SetSSLError("Accept / SSL_set_fd");
return false;