]> source.dussan.org Git - tigervnc.git/commitdiff
Use std::min replace min 1783/head
authorKang Lin <kl222@126.com>
Thu, 25 Jul 2024 03:32:48 +0000 (11:32 +0800)
committerKang Lin <kl222@126.com>
Fri, 26 Jul 2024 01:56:13 +0000 (09:56 +0800)
common/rdr/CMakeLists.txt
common/rdr/HexInStream.cxx
common/rdr/HexOutStream.cxx

index 30c2403a90c60cada127a2a255b6dd73948cf0c6..2897119b259291c4f3fe9035c49ad968ae6aff7a 100644 (file)
@@ -20,6 +20,11 @@ target_include_directories(rdr PUBLIC ${CMAKE_SOURCE_DIR}/common)
 target_include_directories(rdr SYSTEM PUBLIC ${ZLIB_INCLUDE_DIRS})
 target_link_libraries(rdr ${ZLIB_LIBRARIES} os rfb)
 
+if(MSVC)
+  # undef min and max macro
+  target_compile_definitions(rfb PRIVATE NOMINMAX)
+endif()
+
 if(GNUTLS_FOUND)
   target_include_directories(rdr SYSTEM PUBLIC ${GNUTLS_INCLUDE_DIR})
   target_link_libraries(rdr ${GNUTLS_LIBRARIES})
index e23974e1986aee5471ea19907dca40d8a3a72b5d..11f98498eea8f76856c7f2ebba1c9ad44d788f6b 100644 (file)
 #include <config.h>
 #endif
 
+#include <algorithm>
 #include <rdr/HexInStream.h>
 #include <rdr/Exception.h>
 #include <rfb/util.h>
 
 using namespace rdr;
 
-static inline int min(int a, int b) {return a<b ? a : b;}
-
 HexInStream::HexInStream(InStream& is)
 : in_stream(is)
 {
@@ -37,12 +36,11 @@ HexInStream::HexInStream(InStream& is)
 HexInStream::~HexInStream() {
 }
 
-
 bool HexInStream::fillBuffer() {
   if (!in_stream.hasData(2))
     return false;
 
-  size_t length = min(in_stream.avail()/2, availSpace());
+  size_t length = std::min(in_stream.avail()/2, availSpace());
   const uint8_t* iptr = in_stream.getptr(length*2);
 
   uint8_t* optr = (uint8_t*) end;
index b1ab2dc064f7845d172129fa6b3ab22f7e74b61e..efab77f8e3fffb87e8250f3c11df3110d070d025 100644 (file)
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
-
+#include <algorithm>
 #include <rdr/HexOutStream.h>
 #include <rfb/util.h>
 
 using namespace rdr;
 
-static inline size_t min(size_t a, size_t b) {return a<b ? a : b;}
-
 HexOutStream::HexOutStream(OutStream& os)
   : out_stream(os)
 {
@@ -41,7 +39,7 @@ bool HexOutStream::flushBuffer()
 {
   while (sentUpTo != ptr) {
     uint8_t* optr = out_stream.getptr(2);
-    size_t length = min(ptr-sentUpTo, out_stream.avail()/2);
+    size_t length = std::min((size_t)(ptr-sentUpTo), out_stream.avail()/2);
 
     for (size_t i=0; i<length; i++)
       rfb::binToHex(&sentUpTo[i], 1, (char*)&optr[i*2], 2);
@@ -64,4 +62,3 @@ void HexOutStream::cork(bool enable)
   BufferedOutStream::cork(enable);
   out_stream.cork(enable);
 }
-