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
| 506 | * If the source object is NULL the function is guaranteed to return NULL |
| 507 | * and set 'len' to 0. */ |
| 508 | unsigned 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 */ |
| 527 | void setbitCommand(client *c) { |
no test coverage detected