MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / addData

Method addData

src/replication.cpp:1073–1092  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1071 }
1072
1073 void addData(const char *data, unsigned long size) {
1074 if (reply != nullptr && (size + reply->used) > reply->size)
1075 flushData();
1076
1077 if (reply != nullptr && reply->size < size) {
1078 serverAssert(reply->used == 0); // flush should have happened
1079 zfree(reply);
1080 reply = nullptr;
1081 }
1082
1083 if (reply == nullptr) {
1084 reply = (clientReplyBlock*)zmalloc(sizeof(clientReplyBlock) + std::max(size, (unsigned long)(PROTO_REPLY_CHUNK_BYTES*64)));
1085 reply->size = zmalloc_usable_size(reply) - sizeof(clientReplyBlock);
1086 reply->used = 0;
1087 }
1088
1089 serverAssert((reply->size - reply->used) >= size);
1090 memcpy(reply->buf() + reply->used, data, size);
1091 reply->used += size;
1092 }
1093
1094 void addLongLongWithPrefix(long long val, char prefix) {
1095 char buf[128];

Callers

nothing calls this directly

Calls 4

zfreeFunction · 0.85
zmallocFunction · 0.85
zmalloc_usable_sizeFunction · 0.85
bufMethod · 0.45

Tested by

no test coverage detected