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