Skip to content

Commit

Permalink
Use std::min replace min for cross-platform
Browse files Browse the repository at this point in the history
  • Loading branch information
KangLin committed Jul 22, 2024
1 parent 422444a commit 38ec9eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions common/rdr/HexInStream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
#include <rdr/HexInStream.h>
#include <rdr/Exception.h>
#include <rfb/util.h>
#include <algorithm>

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 @@ -41,8 +40,8 @@ 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
5 changes: 2 additions & 3 deletions common/rdr/HexOutStream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@

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

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 +40,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(ptr-sentUpTo, (int64_t)out_stream.avail()/2);

for (size_t i=0; i<length; i++)
rfb::binToHex(&sentUpTo[i], 1, (char*)&optr[i*2], 2);
Expand Down

0 comments on commit 38ec9eb

Please sign in to comment.