MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rewriteClientCommandArgument

Function rewriteClientCommandArgument

app/redis-6.2.6/src/networking.c:3141–3161  ·  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

3139 * want to end with, it's up to the caller to set c->argc and
3140 * free the no longer used objects on c->argv. */
3141void rewriteClientCommandArgument(client *c, int i, robj *newval) {
3142 robj *oldval;
3143 retainOriginalCommandVector(c);
3144 if (i >= c->argc) {
3145 c->argv = zrealloc(c->argv,sizeof(robj*)*(i+1));
3146 c->argc = i+1;
3147 c->argv[i] = NULL;
3148 }
3149 oldval = c->argv[i];
3150 if (oldval) c->argv_len_sum -= getStringObjectLen(oldval);
3151 if (newval) c->argv_len_sum += getStringObjectLen(newval);
3152 c->argv[i] = newval;
3153 incrRefCount(newval);
3154 if (oldval) decrRefCount(oldval);
3155
3156 /* If this is the command name make sure to fix c->cmd. */
3157 if (i == 0) {
3158 c->cmd = lookupCommandOrOriginal(c->argv[0]->ptr);
3159 serverAssertWithInfo(c,NULL,c->cmd != NULL);
3160 }
3161}
3162
3163/* This function returns the number of bytes that Redis is
3164 * using to store the reply still not read by the client.

Callers 7

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

Calls 6

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

Tested by

no test coverage detected