Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use std::min replace min #1783

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions common/rdr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
6 changes: 2 additions & 4 deletions common/rdr/HexInStream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@
#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)
{
Expand All @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions common/rdr/HexOutStream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@
#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)
{
Expand All @@ -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);
Expand All @@ -64,4 +62,3 @@ void HexOutStream::cork(bool enable)
BufferedOutStream::cork(enable);
out_stream.cork(enable);
}

Loading