----------------------------------------------------------------------------- * Higher level functions to queue data on the client output buffer. * The following functions are the ones that commands implementations will call. * -------------------------------------------------------------------------- */ Add the object 'obj' string representation to the client output buffer. */
| 441 | * -------------------------------------------------------------------------- */ |
| 442 | /* Add the object 'obj' string representation to the client output buffer. */ |
| 443 | void addReply(client *c, robj_roptr obj) { |
| 444 | if (prepareClientToWrite(c) != C_OK) return; |
| 445 | |
| 446 | if (sdsEncodedObject(obj)) { |
| 447 | if (_addReplyToBuffer(c,(const char*)ptrFromObj(obj),sdslen((sds)ptrFromObj(obj))) != C_OK) |
| 448 | _addReplyProtoToList(c,(const char*)ptrFromObj(obj),sdslen((sds)ptrFromObj(obj))); |
| 449 | } else if (obj->encoding == OBJ_ENCODING_INT) { |
| 450 | /* For integer encoded strings we just convert it into a string |
| 451 | * using our optimized function, and attach the resulting string |
| 452 | * to the output buffer. */ |
| 453 | char buf[32]; |
| 454 | size_t len = ll2string(buf,sizeof(buf),(long)ptrFromObj(obj)); |
| 455 | if (_addReplyToBuffer(c,buf,len) != C_OK) |
| 456 | _addReplyProtoToList(c,buf,len); |
| 457 | } else { |
| 458 | serverPanic("Wrong obj->encoding in addReply()"); |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | /* Add the SDS 's' string to the client output buffer, as a side effect |
| 463 | * the SDS string is freed. */ |
no test coverage detected