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

Function getStringObjectSdsUsedMemory

src/networking.cpp:55–62  ·  view source on GitHub ↗

Return the amount of memory used by the sds string at object->ptr * for a string object. This includes internal fragmentation. */

Source from the content-addressed store, hash-verified

53/* Return the amount of memory used by the sds string at object->ptr
54 * for a string object. This includes internal fragmentation. */
55size_t getStringObjectSdsUsedMemory(robj *o) {
56 serverAssertWithInfo(NULL,o,o->type == OBJ_STRING);
57 switch(o->encoding) {
58 case OBJ_ENCODING_RAW: return sdsZmallocSize((sds)ptrFromObj(o));
59 case OBJ_ENCODING_EMBSTR: return zmalloc_size(allocPtrFromObj(o))-sizeof(robj);
60 default: return 0; /* Just integer encoding for now. */
61 }
62}
63
64/* Return the length of a string object.
65 * This does NOT includes internal fragmentation or sds unused space. */

Callers 3

addEntryMethod · 0.85
debugCommandFunction · 0.85
luaCreateFunctionFunction · 0.85

Calls 4

sdsZmallocSizeFunction · 0.85
ptrFromObjFunction · 0.85
zmalloc_sizeFunction · 0.85
allocPtrFromObjFunction · 0.85

Tested by

no test coverage detected