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

Function writeProtoNum

src/replication.cpp:527–545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

525}
526
527static int writeProtoNum(char *dst, const size_t cchdst, long long num)
528{
529 if (cchdst < 1)
530 return 0;
531 dst[0] = '$';
532 int cch = 1;
533 cch += ll2string(dst + cch, cchdst - cch, digits10(num));
534 int chCpyT = std::min<int>(cchdst - cch, 2);
535 memcpy(dst + cch, "\r\n", chCpyT);
536 cch += chCpyT;
537 cch += ll2string(dst + cch, cchdst-cch, num);
538 chCpyT = std::min<int>(cchdst - cch, 3);
539 memcpy(dst + cch, "\r\n", chCpyT);
540 if (chCpyT == 3)
541 cch += 2;
542 else
543 cch += chCpyT;
544 return cch;
545}
546
547int canFeedReplicaReplBuffer(client *replica) {
548 /* Don't feed replicas that only want the RDB. */

Callers 1

Calls 2

ll2stringFunction · 0.85
digits10Function · 0.85

Tested by

no test coverage detected