MCPcopy Create free account
hub / github.com/antirez/ds4 / raxIteratorAddChars

Function raxIteratorAddChars

rax.c:1529–1549  ·  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

1527 * is a low level function used to implement the iterator, not callable by
1528 * the user. Returns 0 on out of memory, otherwise 1 is returned. */
1529int raxIteratorAddChars(raxIterator *it, unsigned char *s, size_t len) {
1530 if (len == 0) return 1;
1531 if (it->key_max < it->key_len+len) {
1532 int from_static = it->key == it->key_static_string;
1533 unsigned char *old = from_static ? NULL : it->key;
1534 size_t new_max = (it->key_len+len)*2;
1535 unsigned char *new_key = rax_realloc(old,new_max);
1536 if (new_key == NULL) {
1537 errno = ENOMEM;
1538 return 0;
1539 }
1540 it->key = new_key;
1541 if (from_static) memcpy(it->key,it->key_static_string,it->key_len);
1542 it->key_max = new_max;
1543 }
1544 /* Use memmove since there could be an overlap between 's' and
1545 * it->key when we use the current key in order to re-seek. */
1546 memmove(it->key+it->key_len,s,len);
1547 it->key_len += len;
1548 return 1;
1549}
1550
1551/* Remove the specified number of chars from the right of the current
1552 * iterator key. */

Callers 3

raxIteratorEnterChildFunction · 0.85
raxSeekFunction · 0.85
raxRandomWalkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected