MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / DoraXrtHttpStreamAppend

Function DoraXrtHttpStreamAppend

Source/Http/XrtHttpClient.c:191–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

189}
190
191static int DoraXrtHttpStreamAppend(DoraXrtHttpStreamContext* ctx, const char* data, size_t len) {
192 char* newBuf;
193 size_t newCap;
194 if (!ctx || !data || len == 0u) {
195 return 1;
196 }
197 if (ctx->pendingLen + len + 1u <= ctx->pendingCap) {
198 memcpy(ctx->pending + ctx->pendingLen, data, len);
199 ctx->pendingLen += len;
200 ctx->pending[ctx->pendingLen] = '\0';
201 return 1;
202 }
203 newCap = ctx->pendingCap ? ctx->pendingCap : 4096u;
204 while (newCap < ctx->pendingLen + len + 1u) {
205 newCap *= 2u;
206 }
207 newBuf = (char*)realloc(ctx->pending, newCap);
208 if (!newBuf) {
209 return 0;
210 }
211 ctx->pending = newBuf;
212 ctx->pendingCap = newCap;
213 memcpy(ctx->pending + ctx->pendingLen, data, len);
214 ctx->pendingLen += len;
215 ctx->pending[ctx->pendingLen] = '\0';
216 return 1;
217}
218
219static void DoraXrtHttpStreamConsume(DoraXrtHttpStreamContext* ctx, size_t len) {
220 if (!ctx || len == 0u) {

Callers 1

DoraXrtHttpStreamOnRecvFunction · 0.85

Calls 2

memcpyFunction · 0.50
reallocFunction · 0.50

Tested by

no test coverage detected