Skip to content

Commit

Permalink
Use std::min replace min
Browse files Browse the repository at this point in the history
  • Loading branch information
KangLin committed Jul 25, 2024
1 parent f826691 commit 8dca051
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
12 changes: 7 additions & 5 deletions common/rdr/HexInStream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
#include <config.h>
#endif

#include <algorithm>
#include <rdr/HexInStream.h>
#include <rdr/Exception.h>
#include <rfb/util.h>

using namespace rdr;
#if defined(_MSC_VER)
#undef min
#endif

static inline int min(int a, int b) {return a<b ? a : b;}
using namespace rdr;

HexInStream::HexInStream(InStream& is)
: in_stream(is)
Expand All @@ -37,12 +40,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
11 changes: 6 additions & 5 deletions common/rdr/HexOutStream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <algorithm>
#include <rdr/HexOutStream.h>
#include <rfb/util.h>

using namespace rdr;
#if defined(_MSC_VER)
#undef min
#endif

static inline size_t min(size_t a, size_t b) {return a<b ? a : b;}
using namespace rdr;

HexOutStream::HexOutStream(OutStream& os)
: out_stream(os)
Expand All @@ -41,7 +43,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 +66,3 @@ void HexOutStream::cork(bool enable)
BufferedOutStream::cork(enable);
out_stream.cork(enable);
}

0 comments on commit 8dca051

Please sign in to comment.