Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
c026b5cd
Commit
c026b5cd
authored
Jun 23, 2016
by
antirez
Browse files
Merge branch 'unstable' of github.com:/antirez/redis into unstable
parents
0f484d83
28ea585f
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
c026b5cd
...
...
@@ -687,6 +687,17 @@ RedisModuleString *RM_CreateStringFromLongLong(RedisModuleCtx *ctx, long long ll
return
RM_CreateString
(
ctx
,
buf
,
len
);
}
/* Like RedisModule_CreatString(), but creates a string starting from another
* RedisModuleString.
*
* The returned string must be released with RedisModule_FreeString() or by
* enabling automatic memory management. */
RedisModuleString
*
RM_CreateStringFromString
(
RedisModuleCtx
*
ctx
,
const
RedisModuleString
*
str
)
{
RedisModuleString
*
o
=
dupStringObject
(
str
);
autoMemoryAdd
(
ctx
,
REDISMODULE_AM_STRING
,
o
);
return
o
;
}
/* Free a module string object obtained with one of the Redis modules API calls
* that return new string objects.
*
...
...
@@ -2887,6 +2898,7 @@ void moduleRegisterCoreAPI(void) {
REGISTER_API
(
CreateStringFromCallReply
);
REGISTER_API
(
CreateString
);
REGISTER_API
(
CreateStringFromLongLong
);
REGISTER_API
(
CreateStringFromString
);
REGISTER_API
(
FreeString
);
REGISTER_API
(
StringPtrLen
);
REGISTER_API
(
AutoMemory
);
...
...
src/modules/API.md
View file @
c026b5cd
...
...
@@ -179,6 +179,16 @@ integer instead of taking a buffer and its length.
The returned string must be released with
`RedisModule_FreeString()`
or by
enabling automatic memory management.
## `RM_CreateStringFromString`
RedisModuleString *RM_CreateStringFromString(RedisModuleCtx *ctx, const RedisModuleString *str);
Like
`RedisModule_CreatString()`
, but creates a string starting from an existing
RedisModuleString.
The returned string must be released with
`RedisModule_FreeString()`
or by
enabling automatic memory management.
## `RM_FreeString`
void RM_FreeString(RedisModuleCtx *ctx, RedisModuleString *str);
...
...
src/object.c
View file @
c026b5cd
...
...
@@ -147,7 +147,7 @@ robj *createStringObjectFromLongDouble(long double value, int humanfriendly) {
* will always result in a fresh object that is unshared (refcount == 1).
*
* The resulting object always has refcount set to 1. */
robj
*
dupStringObject
(
robj
*
o
)
{
robj
*
dupStringObject
(
const
robj
*
o
)
{
robj
*
d
;
serverAssert
(
o
->
type
==
OBJ_STRING
);
...
...
src/redismodule.h
View file @
c026b5cd
...
...
@@ -122,6 +122,7 @@ size_t REDISMODULE_API_FUNC(RedisModule_CallReplyLength)(RedisModuleCallReply *r
RedisModuleCallReply
*
REDISMODULE_API_FUNC
(
RedisModule_CallReplyArrayElement
)(
RedisModuleCallReply
*
reply
,
size_t
idx
);
RedisModuleString
*
REDISMODULE_API_FUNC
(
RedisModule_CreateString
)(
RedisModuleCtx
*
ctx
,
const
char
*
ptr
,
size_t
len
);
RedisModuleString
*
REDISMODULE_API_FUNC
(
RedisModule_CreateStringFromLongLong
)(
RedisModuleCtx
*
ctx
,
long
long
ll
);
RedisModuleString
*
REDISMODULE_API_FUNC
(
RedisModule_CreateStringFromString
)(
RedisModuleCtx
*
ctx
,
const
RedisModuleString
*
str
);
void
REDISMODULE_API_FUNC
(
RedisModule_FreeString
)(
RedisModuleCtx
*
ctx
,
RedisModuleString
*
str
);
const
char
*
REDISMODULE_API_FUNC
(
RedisModule_StringPtrLen
)(
const
RedisModuleString
*
str
,
size_t
*
len
);
int
REDISMODULE_API_FUNC
(
RedisModule_ReplyWithError
)(
RedisModuleCtx
*
ctx
,
const
char
*
err
);
...
...
@@ -226,6 +227,7 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int
REDISMODULE_GET_API
(
CreateStringFromCallReply
);
REDISMODULE_GET_API
(
CreateString
);
REDISMODULE_GET_API
(
CreateStringFromLongLong
);
REDISMODULE_GET_API
(
CreateStringFromString
);
REDISMODULE_GET_API
(
FreeString
);
REDISMODULE_GET_API
(
StringPtrLen
);
REDISMODULE_GET_API
(
AutoMemory
);
...
...
src/server.h
View file @
c026b5cd
...
...
@@ -1285,7 +1285,7 @@ robj *createObject(int type, void *ptr);
robj
*
createStringObject
(
const
char
*
ptr
,
size_t
len
);
robj
*
createRawStringObject
(
const
char
*
ptr
,
size_t
len
);
robj
*
createEmbeddedStringObject
(
const
char
*
ptr
,
size_t
len
);
robj
*
dupStringObject
(
robj
*
o
);
robj
*
dupStringObject
(
const
robj
*
o
);
int
isSdsRepresentableAsLongLong
(
sds
s
,
long
long
*
llval
);
int
isObjectRepresentableAsLongLong
(
robj
*
o
,
long
long
*
llongval
);
robj
*
tryObjectEncoding
(
robj
*
o
);
...
...
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