mirror of
https://github.com/fluencelabs/redis
synced 2025-03-17 16:10:50 +00:00
Modules: RM_HashSet() SDS ownership business clarified in comments.
Related to #3239.
This commit is contained in:
parent
01a83d0a2a
commit
e3edae957b
10
src/module.c
10
src/module.c
@ -1788,18 +1788,18 @@ int RM_HashSet(RedisModuleKey *key, int flags, ...) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int low_flags = HASH_SET_COPY;
|
||||
/* If CFIELDS is active, we can pass the ownership of the
|
||||
* SDS object to the low level function that sets the field
|
||||
* to avoid a useless copy. */
|
||||
int low_flags = HASH_SET_COPY;
|
||||
if (flags & REDISMODULE_HASH_CFIELDS)
|
||||
low_flags |= HASH_SET_TAKE_FIELD;
|
||||
updated += hashTypeSet(key->value, field->ptr, value->ptr, low_flags);
|
||||
|
||||
/* If CFIELDS is active, ownership is now of hashTypeSet() */
|
||||
|
||||
/* If CFIELDS is active, SDS string ownership is now of hashTypeSet(),
|
||||
* however we still have to release the 'field' object shell. */
|
||||
if (flags & REDISMODULE_HASH_CFIELDS) {
|
||||
field->ptr = NULL;
|
||||
/* Cleanup */
|
||||
field->ptr = NULL; /* Prevent the SDS string from being freed. */
|
||||
decrRefCount(field);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user