MCPcopy Create free account
hub / github.com/F-Stack/f-stack / getObjectReadOnlyString

Function getObjectReadOnlyString

app/redis-6.2.6/src/bitops.c:508–524  ·  view source on GitHub ↗

Return a pointer to the string object content, and stores its length * in 'len'. The user is required to pass (likely stack allocated) buffer * 'llbuf' of at least LONG_STR_SIZE bytes. Such a buffer is used in the case * the object is integer encoded in order to provide the representation * without using heap allocation. * * The function returns the pointer to the object array of bytes repre

Source from the content-addressed store, hash-verified

506 * If the source object is NULL the function is guaranteed to return NULL
507 * and set 'len' to 0. */
508unsigned char *getObjectReadOnlyString(robj *o, long *len, char *llbuf) {
509 serverAssert(o->type == OBJ_STRING);
510 unsigned char *p = NULL;
511
512 /* Set the 'p' pointer to the string, that can be just a stack allocated
513 * array if our string was integer encoded. */
514 if (o && o->encoding == OBJ_ENCODING_INT) {
515 p = (unsigned char*) llbuf;
516 if (len) *len = ll2string(llbuf,LONG_STR_SIZE,(long)o->ptr);
517 } else if (o) {
518 p = (unsigned char*) o->ptr;
519 if (len) *len = sdslen(o->ptr);
520 } else {
521 if (len) *len = 0;
522 }
523 return p;
524}
525
526/* SETBIT key offset bitvalue */
527void setbitCommand(client *c) {

Callers 3

bitcountCommandFunction · 0.85
bitposCommandFunction · 0.85
bitfieldGenericFunction · 0.85

Calls 2

ll2stringFunction · 0.85
sdslenFunction · 0.85

Tested by

no test coverage detected