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
a68c19df
Commit
a68c19df
authored
Nov 04, 2019
by
artix
Browse files
RM_CreateStringFromLongDouble: use new ld2string 'mode' type
parent
060af185
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
a68c19df
...
@@ -1022,7 +1022,8 @@ RedisModuleString *RM_CreateStringFromLongLong(RedisModuleCtx *ctx, long long ll
...
@@ -1022,7 +1022,8 @@ RedisModuleString *RM_CreateStringFromLongLong(RedisModuleCtx *ctx, long long ll
* RedisModule_CreateString() documentation for more info. */
* RedisModule_CreateString() documentation for more info. */
RedisModuleString
*
RM_CreateStringFromLongDouble
(
RedisModuleCtx
*
ctx
,
long
double
ld
,
int
humanfriendly
)
{
RedisModuleString
*
RM_CreateStringFromLongDouble
(
RedisModuleCtx
*
ctx
,
long
double
ld
,
int
humanfriendly
)
{
char
buf
[
MAX_LONG_DOUBLE_CHARS
];
char
buf
[
MAX_LONG_DOUBLE_CHARS
];
size_t
len
=
ld2string
(
buf
,
sizeof
(
buf
),
ld
,
humanfriendly
);
size_t
len
=
ld2string
(
buf
,
sizeof
(
buf
),
ld
,
(
humanfriendly
?
LD_STR_HUMAN
:
LD_STR_AUTO
));
return
RM_CreateString
(
ctx
,
buf
,
len
);
return
RM_CreateString
(
ctx
,
buf
,
len
);
}
}
...
...
tests/modules/misc.c
View file @
a68c19df
...
@@ -6,6 +6,8 @@
...
@@ -6,6 +6,8 @@
#include <unistd.h>
#include <unistd.h>
#include <errno.h>
#include <errno.h>
#define UNUSED(x) (void)(x)
int
test_call_generic
(
RedisModuleCtx
*
ctx
,
RedisModuleString
**
argv
,
int
argc
)
int
test_call_generic
(
RedisModuleCtx
*
ctx
,
RedisModuleString
**
argv
,
int
argc
)
{
{
if
(
argc
<
2
)
{
if
(
argc
<
2
)
{
...
@@ -41,6 +43,8 @@ int test_call_info(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
...
@@ -41,6 +43,8 @@ int test_call_info(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
}
}
int
test_ld_conv
(
RedisModuleCtx
*
ctx
,
RedisModuleString
**
argv
,
int
argc
)
{
int
test_ld_conv
(
RedisModuleCtx
*
ctx
,
RedisModuleString
**
argv
,
int
argc
)
{
UNUSED
(
argv
);
UNUSED
(
argc
);
long
double
ld
=
0
.
00000000000000001L
;
long
double
ld
=
0
.
00000000000000001L
;
const
char
*
ldstr
=
"0.00000000000000001"
;
const
char
*
ldstr
=
"0.00000000000000001"
;
RedisModuleString
*
s1
=
RedisModule_CreateStringFromLongDouble
(
ctx
,
ld
,
1
);
RedisModuleString
*
s1
=
RedisModule_CreateStringFromLongDouble
(
ctx
,
ld
,
1
);
...
...
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