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

Function raxIteratorAddChars

src/rax.c:1272–1291  ·  view source on GitHub ↗

Append characters at the current key string of the iterator 'it'. This * is a low level function used to implement the iterator, not callable by * the user. Returns 0 on out of memory, otherwise 1 is returned. */

Source from the content-addressed store, hash-verified

1270 * is a low level function used to implement the iterator, not callable by
1271 * the user. Returns 0 on out of memory, otherwise 1 is returned. */
1272int raxIteratorAddChars(raxIterator *it, unsigned char *s, size_t len) {
1273 if (it->key_max < it->key_len+len) {
1274 unsigned char *old = (it->key == it->key_static_string) ? NULL :
1275 it->key;
1276 size_t new_max = (it->key_len+len)*2;
1277 it->key = rax_realloc(old,new_max);
1278 if (it->key == NULL) {
1279 it->key = (!old) ? it->key_static_string : old;
1280 errno = ENOMEM;
1281 return 0;
1282 }
1283 if (old == NULL) memcpy(it->key,it->key_static_string,it->key_len);
1284 it->key_max = new_max;
1285 }
1286 /* Use memmove since there could be an overlap between 's' and
1287 * it->key when we use the current key in order to re-seek. */
1288 memmove(it->key+it->key_len,s,len);
1289 it->key_len += len;
1290 return 1;
1291}
1292
1293/* Remove the specified number of chars from the right of the current
1294 * iterator key. */

Callers 5

raxIteratorNextStepFunction · 0.85
raxSeekGreatestFunction · 0.85
raxIteratorPrevStepFunction · 0.85
raxSeekFunction · 0.85
raxRandomWalkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected