summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2016-05-18 16:17:46 +0200
committerantirez <antirez@gmail.com>2016-05-18 16:30:20 +0200
commite3edae957b7c4d5f1194828bf342397bc9fa6515 (patch)
tree635c4ae02532fba749f664f0ce6f774244b6e6a8 /src
parent01a83d0a2ae1450118b2230d47c613bb9fc07952 (diff)
downloadredis-e3edae957b7c4d5f1194828bf342397bc9fa6515.tar.gz
Modules: RM_HashSet() SDS ownership business clarified in comments.
Related to #3239.
Diffstat (limited to 'src')
-rw-r--r--src/module.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/module.c b/src/module.c
index dab34a3d2..6a8a5f5b0 100644
--- a/src/module.c
+++ b/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);
}
}