Lines Matching refs:pBuf
59 void expandBufFree(ExpandBuf* pBuf) { in expandBufFree() argument
60 if (pBuf == nullptr) { in expandBufFree()
64 free(pBuf->storage); in expandBufFree()
65 delete pBuf; in expandBufFree()
71 uint8_t* expandBufGetBuffer(ExpandBuf* pBuf) { in expandBufGetBuffer() argument
72 return pBuf->storage; in expandBufGetBuffer()
78 size_t expandBufGetLength(ExpandBuf* pBuf) { in expandBufGetLength() argument
79 return pBuf->curLen; in expandBufGetLength()
86 static void ensureSpace(ExpandBuf* pBuf, int newCount) { in ensureSpace() argument
87 if (pBuf->curLen + newCount <= pBuf->maxLen) { in ensureSpace()
91 while (pBuf->curLen + newCount > pBuf->maxLen) { in ensureSpace()
92 pBuf->maxLen *= 2; in ensureSpace()
95 uint8_t* newPtr = reinterpret_cast<uint8_t*>(realloc(pBuf->storage, pBuf->maxLen)); in ensureSpace()
97 LOG(FATAL) << "realloc(" << pBuf->maxLen << ") failed"; in ensureSpace()
100 pBuf->storage = newPtr; in ensureSpace()
106 uint8_t* expandBufAddSpace(ExpandBuf* pBuf, int gapSize) { in expandBufAddSpace() argument
109 ensureSpace(pBuf, gapSize); in expandBufAddSpace()
110 gapStart = pBuf->storage + pBuf->curLen; in expandBufAddSpace()
112 pBuf->curLen += gapSize; in expandBufAddSpace()
120 void expandBufAdd1(ExpandBuf* pBuf, uint8_t val) { in expandBufAdd1() argument
121 ensureSpace(pBuf, sizeof(val)); in expandBufAdd1()
122 *(pBuf->storage + pBuf->curLen) = val; in expandBufAdd1()
123 pBuf->curLen++; in expandBufAdd1()
129 void expandBufAdd2BE(ExpandBuf* pBuf, uint16_t val) { in expandBufAdd2BE() argument
130 ensureSpace(pBuf, sizeof(val)); in expandBufAdd2BE()
131 Set2BE(pBuf->storage + pBuf->curLen, val); in expandBufAdd2BE()
132 pBuf->curLen += sizeof(val); in expandBufAdd2BE()
138 void expandBufAdd4BE(ExpandBuf* pBuf, uint32_t val) { in expandBufAdd4BE() argument
139 ensureSpace(pBuf, sizeof(val)); in expandBufAdd4BE()
140 Set4BE(pBuf->storage + pBuf->curLen, val); in expandBufAdd4BE()
141 pBuf->curLen += sizeof(val); in expandBufAdd4BE()
147 void expandBufAdd8BE(ExpandBuf* pBuf, uint64_t val) { in expandBufAdd8BE() argument
148 ensureSpace(pBuf, sizeof(val)); in expandBufAdd8BE()
149 Set8BE(pBuf->storage + pBuf->curLen, val); in expandBufAdd8BE()
150 pBuf->curLen += sizeof(val); in expandBufAdd8BE()
166 void expandBufAddUtf8String(ExpandBuf* pBuf, const char* s) { in expandBufAddUtf8String() argument
168 ensureSpace(pBuf, sizeof(uint32_t) + strLen); in expandBufAddUtf8String()
169 SetUtf8String(pBuf->storage + pBuf->curLen, s, strLen); in expandBufAddUtf8String()
170 pBuf->curLen += sizeof(uint32_t) + strLen; in expandBufAddUtf8String()
173 void expandBufAddUtf8String(ExpandBuf* pBuf, const std::string& s) { in expandBufAddUtf8String() argument
174 ensureSpace(pBuf, sizeof(uint32_t) + s.size()); in expandBufAddUtf8String()
175 SetUtf8String(pBuf->storage + pBuf->curLen, s.data(), s.size()); in expandBufAddUtf8String()
176 pBuf->curLen += sizeof(uint32_t) + s.size(); in expandBufAddUtf8String()