From bebadb9012ec88526b925059bdbe13d04fdaeaec Mon Sep 17 00:00:00 2001 From: Sean Middleditch Date: Fri, 3 Oct 2014 20:24:04 -0700 Subject: [PATCH] 64-bit fixes `int` values are not the same thing as `size_t` nor `ptrdiff_t`. Convert incorrect uses of `int` to more appropriate types. Fixes warnings for 64-bit compilations. --- imgui.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 3232c7e2..16110ed6 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -397,9 +397,9 @@ static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t) static inline float ImLength(const ImVec2& lhs) { return sqrt(lhs.x*lhs.x + lhs.y*lhs.y); } static int ImTextCharToUtf8(char* buf, size_t buf_size, unsigned int in_char); // return output UTF-8 bytes count -static int ImTextStrToUtf8(char* buf, size_t buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count +static ptrdiff_t ImTextStrToUtf8(char* buf, size_t buf_size, const ImWchar* in_text, const ImWchar* in_text_end); // return output UTF-8 bytes count static int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const char* in_text_end); // return input UTF-8 bytes count -static int ImTextStrFromUtf8(ImWchar* buf, size_t buf_size, const char* in_text, const char* in_text_end); // return input UTF-8 bytes count +static ptrdiff_t ImTextStrFromUtf8(ImWchar* buf, size_t buf_size, const char* in_text, const char* in_text_end); // return input UTF-8 bytes count static int ImStricmp(const char* str1, const char* str2) { @@ -5515,7 +5515,7 @@ static int ImTextCharFromUtf8(unsigned int* out_char, const char* in_text, const return 0; } -static int ImTextStrFromUtf8(ImWchar* buf, size_t buf_size, const char* in_text, const char* in_text_end) +static ptrdiff_t ImTextStrFromUtf8(ImWchar* buf, size_t buf_size, const char* in_text, const char* in_text_end) { ImWchar* buf_out = buf; ImWchar* buf_end = buf + buf_size; @@ -5535,8 +5535,8 @@ static int ImTextCharToUtf8(char* buf, size_t buf_size, unsigned int c) { if (c) { - int i = 0; - int n = (size_t)buf_size; + size_t i = 0; + size_t n = buf_size; if (c < 0x80) { if (i+1 > n) return 0; @@ -5575,7 +5575,7 @@ static int ImTextCharToUtf8(char* buf, size_t buf_size, unsigned int c) return 0; } -static int ImTextStrToUtf8(char* buf, size_t buf_size, const ImWchar* in_text, const ImWchar* in_text_end) +static ptrdiff_t ImTextStrToUtf8(char* buf, size_t buf_size, const ImWchar* in_text, const ImWchar* in_text_end) { char* buf_out = buf; const char* buf_end = buf + buf_size;