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

Function mallctl_string

src/debug.cpp:373–398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

371}
372
373void mallctl_string(client *c, robj **argv, int argc) {
374 int rret, wret;
375 char *old;
376 size_t sz = sizeof(old);
377 /* for strings, it seems we need to first get the old value, before overriding it. */
378 if ((rret=mallctl(szFromObj(argv[0]), &old, &sz, NULL, 0))) {
379 /* return error unless this option is write only. */
380 if (!(rret == EPERM && argc > 1)) {
381 addReplyErrorFormat(c,"%s", strerror(rret));
382 return;
383 }
384 }
385 if(argc > 1) {
386 char *val = szFromObj(argv[1]);
387 char **valref = &val;
388 if ((!strcmp(val,"VOID")))
389 valref = NULL, sz = 0;
390 wret = mallctl(szFromObj(argv[0]), NULL, 0, valref, sz);
391 }
392 if (!rret)
393 addReplyBulkCString(c, old);
394 else if (wret)
395 addReplyErrorFormat(c,"%s", strerror(wret));
396 else
397 addReply(c, shared.ok);
398}
399#endif
400
401void debugCommand(client *c) {

Callers 1

debugCommandFunction · 0.85

Calls 4

szFromObjFunction · 0.85
addReplyErrorFormatFunction · 0.85
addReplyBulkCStringFunction · 0.85
addReplyFunction · 0.85

Tested by

no test coverage detected