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

Function getDoubleFromObject

src/object.cpp:656–674  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

654}
655
656int getDoubleFromObject(const robj *o, double *target) {
657 double value;
658
659 if (o == NULL) {
660 value = 0;
661 } else {
662 serverAssertWithInfo(NULL,o,o->type == OBJ_STRING);
663 if (sdsEncodedObject(o)) {
664 if (!string2d(szFromObj(o), sdslen(szFromObj(o)), &value))
665 return C_ERR;
666 } else if (o->encoding == OBJ_ENCODING_INT) {
667 value = (long)ptrFromObj(o);
668 } else {
669 serverPanic("Unknown string encoding");
670 }
671 }
672 *target = value;
673 return C_OK;
674}
675
676int getDoubleFromObjectOrReply(client *c, robj *o, double *target, const char *msg) {
677 double value;

Callers 2

RM_StringToDoubleFunction · 0.85

Calls 4

string2dFunction · 0.85
szFromObjFunction · 0.85
sdslenFunction · 0.85
ptrFromObjFunction · 0.85

Tested by

no test coverage detected