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

Function rewriteClientCommandArgument

src/networking.cpp:3778–3798  ·  view source on GitHub ↗

Rewrite a single item in the command vector. * The new val ref count is incremented, and the old decremented. * * It is possible to specify an argument over the current size of the * argument vector: in this case the array of objects gets reallocated * and c->argc set to the max value. However it's up to the caller to * * 1. Make sure there are no "holes" and all the arguments are set. * 2

Source from the content-addressed store, hash-verified

3776 * want to end with, it's up to the caller to set c->argc and
3777 * free the no longer used objects on c->argv. */
3778void rewriteClientCommandArgument(client *c, int i, robj *newval) {
3779 robj *oldval;
3780 retainOriginalCommandVector(c);
3781 if (i >= c->argc) {
3782 c->argv = (robj**)zrealloc(c->argv,sizeof(robj*)*(i+1), MALLOC_LOCAL);
3783 c->argc = i+1;
3784 c->argv[i] = NULL;
3785 }
3786 oldval = c->argv[i];
3787 if (oldval) c->argv_len_sumActive -= getStringObjectLen(oldval);
3788 if (newval) c->argv_len_sumActive += getStringObjectLen(newval);
3789 c->argv[i] = newval;
3790 incrRefCount(newval);
3791 if (oldval) decrRefCount(oldval);
3792
3793 /* If this is the command name make sure to fix c->cmd. */
3794 if (i == 0) {
3795 c->cmd = lookupCommandOrOriginal((sds)ptrFromObj(c->argv[0]));
3796 serverAssertWithInfo(c,NULL,c->cmd != NULL);
3797 }
3798}
3799
3800/* In the case of a replica client, writes to said replica are using data from the replication backlog
3801 * as opposed to it's own internal buffer, this number should keep track of that */

Callers 7

hincrbyfloatCommandFunction · 0.85
xaddCommandFunction · 0.85
getsetCommandFunction · 0.85
incrbyfloatCommandFunction · 0.85
evalGenericCommandFunction · 0.85

Calls 7

zreallocFunction · 0.85
getStringObjectLenFunction · 0.85
incrRefCountFunction · 0.85
decrRefCountFunction · 0.85
lookupCommandOrOriginalFunction · 0.85
ptrFromObjFunction · 0.85

Tested by

no test coverage detected