manual followup - replacing robj->ptr references with interface calls

Signed-off-by: Rain Valentine <rsg000@gmail.com>
This commit is contained in:
Rain Valentine 2025-12-15 21:14:20 +00:00
parent 3c1879749d
commit a3cd615452
6 changed files with 29 additions and 17 deletions

View File

@ -1215,12 +1215,12 @@ void bitfieldGeneric(client *c, int flags) {
uint64_t highest_write_offset = 0;
for (j = 2; j < c->argc; j++) {
int remargs = c->argc - j - 1; /* Remaining args other than current. */
int remargs = c->argc - j - 1; /* Remaining args other than current. */
char *subcmd = objectGetVal(c->argv[j]); /* Current command name. */
int opcode; /* Current operation code. */
long long i64 = 0; /* Signed SET value. */
int sign = 0; /* Signed or unsigned type? */
int bits = 0; /* Bitfield width in bits. */
int opcode; /* Current operation code. */
long long i64 = 0; /* Signed SET value. */
int sign = 0; /* Signed or unsigned type? */
int bits = 0; /* Bitfield width in bits. */
if (!strcasecmp(subcmd, "get") && remargs >= 2)
opcode = BITFIELDOP_GET;

View File

@ -443,7 +443,10 @@ static void scanLaterHash(robj *ob, unsigned long *cursor) {
static void defragQuicklist(robj *ob) {
quicklist *ql = objectGetVal(ob), *newql;
serverAssert(ob->type == OBJ_LIST && ob->encoding == OBJ_ENCODING_QUICKLIST);
if ((newql = activeDefragAlloc(ql))) objectSetVal(ob, ql = newql);
if ((newql = activeDefragAlloc(ql))) {
objectSetVal(ob, newql);
ql = newql;
}
if (ql->len > server.active_defrag_max_scan_fields)
defragLater(ob);
else
@ -457,7 +460,10 @@ static void defragZsetSkiplist(robj *ob) {
zset *newzs;
zskiplist *newzsl;
struct zskiplistNode *newheader;
if ((newzs = activeDefragAlloc(zs))) objectSetVal(ob, zs = newzs);
if ((newzs = activeDefragAlloc(zs))) {
objectSetVal(ob, newzs);
zs = newzs;
}
if ((newzsl = activeDefragAlloc(zs->zsl))) zs->zsl = newzsl;
if ((newheader = activeDefragAlloc(zs->zsl->header))) zs->zsl->header = newheader;
@ -643,7 +649,10 @@ static void defragStream(robj *ob) {
stream *s = objectGetVal(ob), *news;
/* handle the main struct */
if ((news = activeDefragAlloc(s))) objectSetVal(ob, s = news);
if ((news = activeDefragAlloc(s))) {
objectSetVal(ob, news);
s = news;
}
if (raxSize(s->rax) > server.active_defrag_max_scan_fields) {
rax *newrax = activeDefragAlloc(s->rax);

View File

@ -14113,7 +14113,8 @@ int moduleDefragValue(robj *key, robj *value, int dbid) {
*/
moduleValue *newmv = activeDefragAlloc(mv);
if (newmv) {
objectSetVal(value, mv = newmv);
objectSetVal(value, newmv);
mv = newmv;
}
if (!mt->defrag) return 1;

View File

@ -243,7 +243,7 @@ robj *createStringObjectWithKeyAndExpire(const char *ptr, size_t len, const sds
}
void *objectGetVal(const robj *o) {
return objectGetVal(o);
return o->val_ptr;
}
sds objectGetKey(const robj *o) {
@ -288,7 +288,7 @@ robj *objectSetExpire(robj *o, long long expire) {
}
void objectSetVal(robj *o, void *val) {
objectSetVal(o, val);
o->val_ptr = val;
}
/* This functions may reallocate the value. The new allocation is returned and

View File

@ -796,7 +796,7 @@ struct serverObject {
unsigned hasexpire : 1;
unsigned hasembkey : 1;
unsigned refcount : OBJ_REFCOUNT_BITS;
void *ptr;
void *val_ptr;
};
/* The string name for an object's type as listed above
@ -815,7 +815,7 @@ char *getObjectTypeName(robj *);
_var.encoding = OBJ_ENCODING_RAW; \
_var.hasexpire = 0; \
_var.hasembkey = 0; \
_var.ptr = _ptr; \
_var.val_ptr = _ptr; \
} while (0)
struct evictionPoolEntry; /* Defined in evict.c */

View File

@ -164,13 +164,15 @@ void listTypePush(robj *subject, robj *value, int where) {
quicklistPush(objectGetVal(subject), objectGetVal(value), sdslen(objectGetVal(value)), pos);
}
} else if (subject->encoding == OBJ_ENCODING_LISTPACK) {
unsigned char *new_val = NULL;
if (value->encoding == OBJ_ENCODING_INT) {
subject->ptr = (where == LIST_HEAD) ? lpPrependInteger(objectGetVal(subject), (long)objectGetVal(value))
: lpAppendInteger(objectGetVal(subject), (long)objectGetVal(value));
new_val = (where == LIST_HEAD) ? lpPrependInteger(objectGetVal(subject), (long)objectGetVal(value))
: lpAppendInteger(objectGetVal(subject), (long)objectGetVal(value));
} else {
subject->ptr = (where == LIST_HEAD) ? lpPrepend(objectGetVal(subject), objectGetVal(value), sdslen(objectGetVal(value)))
: lpAppend(objectGetVal(subject), objectGetVal(value), sdslen(objectGetVal(value)));
new_val = (where == LIST_HEAD) ? lpPrepend(objectGetVal(subject), objectGetVal(value), sdslen(objectGetVal(value)))
: lpAppend(objectGetVal(subject), objectGetVal(value), sdslen(objectGetVal(value)));
}
objectSetVal(subject, new_val);
} else {
serverPanic("Unknown list encoding");
}