diff options
author | Pietro Cerutti <gahr@FreeBSD.org> | 2014-07-10 13:08:51 +0000 |
---|---|---|
committer | Pietro Cerutti <gahr@FreeBSD.org> | 2014-07-10 13:08:51 +0000 |
commit | 7150b86bfe2474cebd10c863c1c57f089684f8bc (patch) | |
tree | 0c4dc8a9d1f44507f1648cc9f8160425257f7eeb /sys/sys/sbuf.h | |
parent | 4472d6e1df6bdf98c5bf3f692296e6b2de5cbd55 (diff) | |
download | src-7150b86bfe2474cebd10c863c1c57f089684f8bc.tar.gz src-7150b86bfe2474cebd10c863c1c57f089684f8bc.zip |
Implement Short/Small String Optimization in SBUF(9) and change lengths and
positions in the API from ssize_t and int to size_t.
CR: D388
Approved by: des, bapt
Notes
Notes:
svn path=/head/; revision=268494
Diffstat (limited to 'sys/sys/sbuf.h')
-rw-r--r-- | sys/sys/sbuf.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/sys/sbuf.h b/sys/sys/sbuf.h index 9816a4cd6c54..9c794c830543 100644 --- a/sys/sys/sbuf.h +++ b/sys/sys/sbuf.h @@ -44,8 +44,8 @@ struct sbuf { sbuf_drain_func *s_drain_func; /* drain function */ void *s_drain_arg; /* user-supplied drain argument */ int s_error; /* current error code */ - ssize_t s_size; /* size of storage buffer */ - ssize_t s_len; /* current length of string */ + size_t s_size; /* size of storage buffer */ + size_t s_len; /* current length of string */ #define SBUF_FIXEDLEN 0x00000000 /* fixed length buffer (default) */ #define SBUF_AUTOEXTEND 0x00000001 /* automatically extend buffer */ #define SBUF_USRFLAGMSK 0x0000ffff /* mask of flags the user may specify */ @@ -55,6 +55,9 @@ struct sbuf { #define SBUF_INSECTION 0x00100000 /* set by sbuf_start_section() */ int s_flags; /* flags */ ssize_t s_sect_len; /* current length of section */ +#define SBUF_STATIC_LEN 64 /* static storage buffer length */ + char s_static_buf[SBUF_STATIC_LEN]; + /* static storage buffer */ }; __BEGIN_DECLS @@ -65,7 +68,7 @@ struct sbuf *sbuf_new(struct sbuf *, char *, int, int); #define sbuf_new_auto() \ sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND) void sbuf_clear(struct sbuf *); -int sbuf_setpos(struct sbuf *, ssize_t); +int sbuf_setpos(struct sbuf *, size_t); int sbuf_bcat(struct sbuf *, const void *, size_t); int sbuf_bcpy(struct sbuf *, const void *, size_t); int sbuf_cat(struct sbuf *, const char *); |