Lines Matching refs:pBuf
60 void expandBufFree(ExpandBuf* pBuf) { in expandBufFree() argument
61 if (pBuf == nullptr) { in expandBufFree()
65 free(pBuf->storage); in expandBufFree()
66 delete pBuf; in expandBufFree()
72 uint8_t* expandBufGetBuffer(ExpandBuf* pBuf) { in expandBufGetBuffer() argument
73 return pBuf->storage; in expandBufGetBuffer()
79 size_t expandBufGetLength(ExpandBuf* pBuf) { in expandBufGetLength() argument
80 return pBuf->curLen; in expandBufGetLength()
87 static void ensureSpace(ExpandBuf* pBuf, int newCount) { in ensureSpace() argument
88 if (pBuf->curLen + newCount <= pBuf->maxLen) { in ensureSpace()
92 while (pBuf->curLen + newCount > pBuf->maxLen) { in ensureSpace()
93 pBuf->maxLen *= 2; in ensureSpace()
96 uint8_t* newPtr = reinterpret_cast<uint8_t*>(realloc(pBuf->storage, pBuf->maxLen)); in ensureSpace()
98 LOG(FATAL) << "realloc(" << pBuf->maxLen << ") failed"; in ensureSpace()
101 pBuf->storage = newPtr; in ensureSpace()
107 uint8_t* expandBufAddSpace(ExpandBuf* pBuf, int gapSize) { in expandBufAddSpace() argument
110 ensureSpace(pBuf, gapSize); in expandBufAddSpace()
111 gapStart = pBuf->storage + pBuf->curLen; in expandBufAddSpace()
113 pBuf->curLen += gapSize; in expandBufAddSpace()
121 void expandBufAdd1(ExpandBuf* pBuf, uint8_t val) { in expandBufAdd1() argument
122 ensureSpace(pBuf, sizeof(val)); in expandBufAdd1()
123 *(pBuf->storage + pBuf->curLen) = val; in expandBufAdd1()
124 pBuf->curLen++; in expandBufAdd1()
130 void expandBufAdd2BE(ExpandBuf* pBuf, uint16_t val) { in expandBufAdd2BE() argument
131 ensureSpace(pBuf, sizeof(val)); in expandBufAdd2BE()
132 Set2BE(pBuf->storage + pBuf->curLen, val); in expandBufAdd2BE()
133 pBuf->curLen += sizeof(val); in expandBufAdd2BE()
139 void expandBufAdd4BE(ExpandBuf* pBuf, uint32_t val) { in expandBufAdd4BE() argument
140 ensureSpace(pBuf, sizeof(val)); in expandBufAdd4BE()
141 Set4BE(pBuf->storage + pBuf->curLen, val); in expandBufAdd4BE()
142 pBuf->curLen += sizeof(val); in expandBufAdd4BE()
148 void expandBufAdd8BE(ExpandBuf* pBuf, uint64_t val) { in expandBufAdd8BE() argument
149 ensureSpace(pBuf, sizeof(val)); in expandBufAdd8BE()
150 Set8BE(pBuf->storage + pBuf->curLen, val); in expandBufAdd8BE()
151 pBuf->curLen += sizeof(val); in expandBufAdd8BE()
169 void expandBufAddUtf8String(ExpandBuf* pBuf, const char* s) { in expandBufAddUtf8String() argument
171 ensureSpace(pBuf, sizeof(uint32_t) + strLen); in expandBufAddUtf8String()
172 SetUtf8String(pBuf->storage + pBuf->curLen, s, strLen); in expandBufAddUtf8String()
173 pBuf->curLen += sizeof(uint32_t) + strLen; in expandBufAddUtf8String()
176 void expandBufAddUtf8String(ExpandBuf* pBuf, const std::string& s) { in expandBufAddUtf8String() argument
177 ensureSpace(pBuf, sizeof(uint32_t) + s.size()); in expandBufAddUtf8String()
178 SetUtf8String(pBuf->storage + pBuf->curLen, s.data(), s.size()); in expandBufAddUtf8String()
179 pBuf->curLen += sizeof(uint32_t) + s.size(); in expandBufAddUtf8String()