Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
e3edae95
Commit
e3edae95
authored
May 18, 2016
by
antirez
Browse files
Modules: RM_HashSet() SDS ownership business clarified in comments.
Related to #3239.
parent
01a83d0a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
e3edae95
...
@@ -1788,18 +1788,18 @@ int RM_HashSet(RedisModuleKey *key, int flags, ...) {
...
@@ -1788,18 +1788,18 @@ int RM_HashSet(RedisModuleKey *key, int flags, ...) {
continue;
continue;
}
}
int low_flags = HASH_SET_COPY;
/* If CFIELDS is active, we can pass the ownership of the
/* If CFIELDS is active, we can pass the ownership of the
* SDS object to the low level function that sets the field
* SDS object to the low level function that sets the field
* to avoid a useless copy. */
* to avoid a useless copy. */
int
low_flags
=
HASH_SET_COPY
;
if (flags & REDISMODULE_HASH_CFIELDS)
if (flags & REDISMODULE_HASH_CFIELDS)
low_flags |= HASH_SET_TAKE_FIELD;
low_flags |= HASH_SET_TAKE_FIELD;
updated += hashTypeSet(key->value, field->ptr, value->ptr, low_flags);
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) {
if (flags & REDISMODULE_HASH_CFIELDS) {
field
->
ptr
=
NULL
;
field->ptr = NULL; /* Prevent the SDS string from being freed. */
/* Cleanup */
decrRefCount(field);
decrRefCount(field);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment