diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-08 22:48:01 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-08 22:48:01 +0300 |
commit | cd0de3bd2668294ab3174d3b5f032fefc25fa0e8 (patch) | |
tree | 54942df2cad49260ae466c23fc2af4ec64c03dfb /src | |
parent | 454508376039429ad292de69cd491badda798062 (diff) | |
download | plus-cd0de3bd2668294ab3174d3b5f032fefc25fa0e8.tar.gz plus-cd0de3bd2668294ab3174d3b5f032fefc25fa0e8.tar.bz2 plus-cd0de3bd2668294ab3174d3b5f032fefc25fa0e8.tar.xz plus-cd0de3bd2668294ab3174d3b5f032fefc25fa0e8.zip |
Fix code style in utils.
Diffstat (limited to 'src')
-rw-r--r-- | src/utils/base64.cpp | 5 | ||||
-rw-r--r-- | src/utils/copynpaste.cpp | 6 | ||||
-rw-r--r-- | src/utils/sdlpixel.h | 4 | ||||
-rw-r--r-- | src/utils/stringutils.cpp | 4 |
4 files changed, 10 insertions, 9 deletions
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp index 57bc68a7c..feed37066 100644 --- a/src/utils/base64.cpp +++ b/src/utils/base64.cpp @@ -48,8 +48,9 @@ unsigned char *php3_base64_encode(const unsigned char *restrict const string, { const unsigned char *current = string; int i = 0; - unsigned char *const result = static_cast<unsigned char *>(calloc( - ((length + 3 - length % 3) * 4 / 3 + 1) * sizeof(unsigned char), 1)); + unsigned char *const result = static_cast<unsigned char *>( + calloc(static_cast<size_t>((length + 3 - length % 3) * 4 / 3 + 1) + * sizeof(unsigned char), 1)); if (!result) return nullptr; diff --git a/src/utils/copynpaste.cpp b/src/utils/copynpaste.cpp index 16c9f8958..e4f109d5a 100644 --- a/src/utils/copynpaste.cpp +++ b/src/utils/copynpaste.cpp @@ -81,7 +81,7 @@ bool retrieveBuffer(std::string& text, size_t& pos) if (data) { - const int len = WideCharToMultiByte(CP_UTF8, 0, data, -1, + const size_t len = WideCharToMultiByte(CP_UTF8, 0, data, -1, nullptr, 0, nullptr, nullptr); if (len > 0) { @@ -91,7 +91,7 @@ bool retrieveBuffer(std::string& text, size_t& pos) static_cast<LPSTR>(temp), len, nullptr, nullptr)) { text.insert(pos, static_cast<char*>(temp)); - pos += len-1; + pos += len - 1; } free(temp); ret = true; @@ -128,7 +128,7 @@ bool sendBuffer(std::string& text) return false; HANDLE h = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, - wCharsLen * sizeof(WCHAR)); + static_cast<size_t>(wCharsLen) * sizeof(WCHAR)); WCHAR *const out = static_cast<WCHAR*>(GlobalLock(h)); MultiByteToWideChar(CP_UTF8, 0, text.c_str(), -1, out, wCharsLen); diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h index 282b90afb..5152a68c2 100644 --- a/src/utils/sdlpixel.h +++ b/src/utils/sdlpixel.h @@ -86,7 +86,7 @@ inline void SDLputPixel(SDL_Surface* surface, int x, int y, SDL_LockSurface(surface); Uint8 *const p = static_cast<uint8_t*>(surface->pixels) - + y * surface->pitch + x * bpp; + + static_cast<size_t>(y * surface->pitch + x * bpp); const Uint32 pixel = SDL_MapRGB(surface->format, static_cast<uint8_t>(color.r), static_cast<uint8_t>(color.g), @@ -183,7 +183,7 @@ inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y, SDL_LockSurface(surface); Uint8 *const p = static_cast<uint8_t*>(surface->pixels) - + y * surface->pitch + x * bpp; + + static_cast<size_t>(y * surface->pitch + x * bpp); const Uint32 pixel = SDL_MapRGB(surface->format, static_cast<uint8_t>(color.r), diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index cacb3befd..a5435f3f9 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -32,7 +32,7 @@ #include "debug.h" -static int UTF8_MAX_SIZE = 10; +static size_t UTF8_MAX_SIZE = 10; std::string &trim(std::string &str) { @@ -92,7 +92,7 @@ std::string strprintf(const char *const format, ...) char buf[257]; va_list(args); va_start(args, format); - int nb = vsnprintf(buf, 256, format, args); + size_t nb = vsnprintf(buf, 256, format, args); buf[256] = 0; va_end(args); if (nb < 256) |