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
8af99d0c
Commit
8af99d0c
authored
May 04, 2015
by
Salvatore Sanfilippo
Browse files
Merge pull request #2530 from FuGangqiang/unstable
fix sds.c
parents
5a23ef88
26a1a08f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sds.c
View file @
8af99d0c
...
@@ -71,7 +71,7 @@ sds sdsempty(void) {
...
@@ -71,7 +71,7 @@ sds sdsempty(void) {
return
sdsnewlen
(
""
,
0
);
return
sdsnewlen
(
""
,
0
);
}
}
/* Create a new sds string starting from a null termined C string. */
/* Create a new sds string starting from a null termin
at
ed C string. */
sds
sdsnew
(
const
char
*
init
)
{
sds
sdsnew
(
const
char
*
init
)
{
size_t
initlen
=
(
init
==
NULL
)
?
0
:
strlen
(
init
);
size_t
initlen
=
(
init
==
NULL
)
?
0
:
strlen
(
init
);
return
sdsnewlen
(
init
,
initlen
);
return
sdsnewlen
(
init
,
initlen
);
...
@@ -557,7 +557,7 @@ sds sdscatfmt(sds s, char const *fmt, ...) {
...
@@ -557,7 +557,7 @@ sds sdscatfmt(sds s, char const *fmt, ...) {
* Example:
* Example:
*
*
* s = sdsnew("AA...AA.a.aa.aHelloWorld :::");
* s = sdsnew("AA...AA.a.aa.aHelloWorld :::");
* s = sdstrim(s,"A. :");
* s = sdstrim(s,"A
a
. :");
* printf("%s\n", s);
* printf("%s\n", s);
*
*
* Output will be just "Hello World".
* Output will be just "Hello World".
...
@@ -1098,6 +1098,7 @@ int sdsTest(int argc, char *argv[]) {
...
@@ -1098,6 +1098,7 @@ int sdsTest(int argc, char *argv[]) {
unsigned
int
oldfree
;
unsigned
int
oldfree
;
sdsfree
(
x
);
sdsfree
(
x
);
sdsfree
(
y
);
x
=
sdsnew
(
"0"
);
x
=
sdsnew
(
"0"
);
sh
=
(
void
*
)
(
x
-
(
sizeof
(
struct
sdshdr
)));
sh
=
(
void
*
)
(
x
-
(
sizeof
(
struct
sdshdr
)));
test_cond
(
"sdsnew() free/len buffers"
,
sh
->
len
==
1
&&
sh
->
free
==
0
);
test_cond
(
"sdsnew() free/len buffers"
,
sh
->
len
==
1
&&
sh
->
free
==
0
);
...
@@ -1110,6 +1111,8 @@ int sdsTest(int argc, char *argv[]) {
...
@@ -1110,6 +1111,8 @@ int sdsTest(int argc, char *argv[]) {
test_cond
(
"sdsIncrLen() -- content"
,
x
[
0
]
==
'0'
&&
x
[
1
]
==
'1'
);
test_cond
(
"sdsIncrLen() -- content"
,
x
[
0
]
==
'0'
&&
x
[
1
]
==
'1'
);
test_cond
(
"sdsIncrLen() -- len"
,
sh
->
len
==
2
);
test_cond
(
"sdsIncrLen() -- len"
,
sh
->
len
==
2
);
test_cond
(
"sdsIncrLen() -- free"
,
sh
->
free
==
oldfree
-
1
);
test_cond
(
"sdsIncrLen() -- free"
,
sh
->
free
==
oldfree
-
1
);
sdsfree
(
x
);
}
}
}
}
test_report
()
test_report
()
...
...
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