proxygen
IOBufUtil.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree.
7  */
8 
10 
11 using namespace folly;
12 
13 namespace fizz {
14 
16  auto trim = trimmed.size();
17  size_t currentTrim = trim;
18  IOBuf* current = buf.prev();
19  size_t chainElements = buf.countChainElements();
20  for (size_t i = 0; i < chainElements && currentTrim != 0; ++i) {
21  size_t toTrim =
22  std::min(currentTrim, static_cast<size_t>(current->length()));
23  memcpy(
24  trimmed.begin() + (currentTrim - toTrim),
25  current->data() + (current->length() - toTrim),
26  toTrim);
27  current->trimEnd(toTrim);
28  currentTrim -= toTrim;
29  current = current->prev();
30  }
31 }
32 
34  CHECK_EQ(first.size(), second.size());
35  for (size_t i = 0; i < first.size(); ++i) {
36  second[i] ^= first[i];
37  }
38 };
39 } // namespace fizz
void trimBytes(IOBuf &buf, folly::MutableByteRange trimmed)
Definition: IOBufUtil.cpp:15
constexpr size_type size() const
Definition: Range.h:431
const uint8_t * data() const
Definition: IOBuf.h:499
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
size_t countChainElements() const
Definition: IOBuf.cpp:493
int current
void XOR(ByteRange first, MutableByteRange second)
Definition: IOBufUtil.cpp:33
LogLevel min
Definition: LogLevel.cpp:30
std::size_t length() const
Definition: IOBuf.h:533
Definition: Actions.h:16
IOBuf * prev()
Definition: IOBuf.h:610
constexpr Iter begin() const
Definition: Range.h:452
void trimEnd(std::size_t amount)
Definition: IOBuf.h:718
constexpr detail::First first
Definition: Base-inl.h:2553