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
ded614f8
Commit
ded614f8
authored
Apr 19, 2011
by
Pieter Noordhuis
Browse files
Inline sdslen and sdsavail (thanks to @bitbckt)
parent
9703b1b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/sds.c
View file @
ded614f8
...
@@ -36,11 +36,11 @@
...
@@ -36,11 +36,11 @@
#define SDS_ABORT_ON_OOM
#define SDS_ABORT_ON_OOM
#include "sds.h"
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <ctype.h>
#include <ctype.h>
#include "sds.h"
#include "zmalloc.h"
#include "zmalloc.h"
static
void
sdsOomAbort
(
void
)
{
static
void
sdsOomAbort
(
void
)
{
...
@@ -78,11 +78,6 @@ sds sdsnew(const char *init) {
...
@@ -78,11 +78,6 @@ sds sdsnew(const char *init) {
return
sdsnewlen
(
init
,
initlen
);
return
sdsnewlen
(
init
,
initlen
);
}
}
size_t
sdslen
(
const
sds
s
)
{
struct
sdshdr
*
sh
=
(
void
*
)
(
s
-
(
sizeof
(
struct
sdshdr
)));
return
sh
->
len
;
}
sds
sdsdup
(
const
sds
s
)
{
sds
sdsdup
(
const
sds
s
)
{
return
sdsnewlen
(
s
,
sdslen
(
s
));
return
sdsnewlen
(
s
,
sdslen
(
s
));
}
}
...
@@ -92,11 +87,6 @@ void sdsfree(sds s) {
...
@@ -92,11 +87,6 @@ void sdsfree(sds s) {
zfree
(
s
-
sizeof
(
struct
sdshdr
));
zfree
(
s
-
sizeof
(
struct
sdshdr
));
}
}
size_t
sdsavail
(
sds
s
)
{
struct
sdshdr
*
sh
=
(
void
*
)
(
s
-
(
sizeof
(
struct
sdshdr
)));
return
sh
->
free
;
}
void
sdsupdatelen
(
sds
s
)
{
void
sdsupdatelen
(
sds
s
)
{
struct
sdshdr
*
sh
=
(
void
*
)
(
s
-
(
sizeof
(
struct
sdshdr
)));
struct
sdshdr
*
sh
=
(
void
*
)
(
s
-
(
sizeof
(
struct
sdshdr
)));
int
reallen
=
strlen
(
s
);
int
reallen
=
strlen
(
s
);
...
...
src/sds.h
View file @
ded614f8
...
@@ -42,6 +42,16 @@ struct sdshdr {
...
@@ -42,6 +42,16 @@ struct sdshdr {
char
buf
[];
char
buf
[];
};
};
static
inline
size_t
sdslen
(
const
sds
s
)
{
struct
sdshdr
*
sh
=
(
void
*
)(
s
-
(
sizeof
(
struct
sdshdr
)));
return
sh
->
len
;
}
static
inline
size_t
sdsavail
(
const
sds
s
)
{
struct
sdshdr
*
sh
=
(
void
*
)(
s
-
(
sizeof
(
struct
sdshdr
)));
return
sh
->
free
;
}
sds
sdsnewlen
(
const
void
*
init
,
size_t
initlen
);
sds
sdsnewlen
(
const
void
*
init
,
size_t
initlen
);
sds
sdsnew
(
const
char
*
init
);
sds
sdsnew
(
const
char
*
init
);
sds
sdsempty
();
sds
sdsempty
();
...
...
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