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
| 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. */ |
| 3141 | void 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. |
no test coverage detected