MCPcopy Create free account
hub / github.com/cinience/RedisStudio / append_record

Method append_record

RedisStudio/SSDB/bytes.cpp:104–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104int Buffer::append_record(const Bytes &s){
105 // 16 is the maximum length of literal string of s.size()
106 int size = 16 + s.size() + 1;
107 while(size > this->space()){
108 if(this->grow() == -1){
109 return -1;
110 }
111 }
112
113 char len[16];
114 int num = snprintf(len, sizeof(len), "%d\n", (int)s.size());
115
116 char *p = this->slot();
117 memcpy(p, len, num);
118 p += num;
119
120 memcpy(p, s.data(), s.size());
121 p += s.size();
122
123 *p = '\n';
124 p += 1;
125 this->size_ += (num + s.size() + 1);
126 return (num + s.size() + 1);
127}
128
129int Buffer::append(char c){
130 while(1 > this->space()){

Callers 1

sendMethod · 0.80

Calls 5

spaceMethod · 0.95
growMethod · 0.95
slotMethod · 0.95
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected