Bug 1355037 - Add parentheses to std::min, r=franziskus
authorChris Lee <lee.rinrire@gmail.com>
Tue, 18 Apr 2017 13:29:27 +0200
changeset 13296 59c2b66c5c4231da32e62e94c00412c0c656c291
parent 13295 802ec96a8dd1fe02df12c306c4867d867083b08a
child 13297 7e99f75f196d868e21beb8956257e2fa199d6b6e
push id2150
push userfranziskuskiefer@gmail.com
push dateWed, 19 Apr 2017 05:30:14 +0000
reviewersfranziskus
bugs1355037
Bug 1355037 - Add parentheses to std::min, r=franziskus
cpputil/databuffer.h
--- a/cpputil/databuffer.h
+++ b/cpputil/databuffer.h
@@ -41,17 +41,17 @@ class DataBuffer {
   }
 
   void Allocate(size_t len) {
     delete[] data_;
     data_ = new uint8_t[len ? len : 1];  // Don't depend on new [0].
     len_ = len;
   }
 
-  void Truncate(size_t len) { len_ = std::min(len_, len); }
+  void Truncate(size_t len) { len_ = (std::min)(len_, len); }
 
   void Assign(const DataBuffer& other) { Assign(other.data(), other.len()); }
 
   void Assign(const uint8_t* data, size_t len) {
     if (data) {
       Allocate(len);
       memcpy(static_cast<void*>(data_), static_cast<const void*>(data), len);
     } else {
@@ -121,24 +121,24 @@ class DataBuffer {
 
   void Splice(const uint8_t* ins, size_t ins_len, size_t index,
               size_t remove = 0) {
     assert(ins);
     uint8_t* old_value = data_;
     size_t old_len = len_;
 
     // The amount of stuff remaining from the tail of the old.
-    size_t tail_len = old_len - std::min(old_len, index + remove);
+    size_t tail_len = old_len - (std::min)(old_len, index + remove);
     // The new length: the head of the old, the new, and the tail of the old.
     len_ = index + ins_len + tail_len;
     data_ = new uint8_t[len_ ? len_ : 1];
 
     // The head of the old.
     if (old_value) {
-      Write(0, old_value, std::min(old_len, index));
+      Write(0, old_value, (std::min)(old_len, index));
     }
     // Maybe a gap.
     if (old_value && index > old_len) {
       memset(old_value + index, 0, index - old_len);
     }
     // The new.
     Write(index, ins, ins_len);
     // The tail of the old.