diff options
author | Johannes Löthberg <johannes@kyriasis.com> | 2015-01-19 14:57:15 +0100 |
---|---|---|
committer | Johannes Löthberg <johannes@kyriasis.com> | 2015-01-19 14:57:15 +0100 |
commit | ec10d90906a8715a80e8f2d4fcd394a7a59c31eb (patch) | |
tree | 5d617340f7bd8136e3e62403df1363e4b0b6cd6b /src/sds.h | |
parent | 8b0a680511b9794fa07154ebfa53f71ad6a108d4 (diff) | |
parent | 8d3aabccc040414cfddd0bdfcc1fa3cbe741c784 (diff) | |
download | sds-ec10d90906a8715a80e8f2d4fcd394a7a59c31eb.tar.xz |
Merge branch 'casts'
In this branch explicit casts were added everywhere were necessary, and
size_t is used for sizes instead of ints. This fixes all warnings when
compiling with -Weverything.
Diffstat (limited to 'src/sds.h')
-rw-r--r-- | src/sds.h | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -31,18 +31,21 @@ #define SDS_MAX_PREALLOC (1024*1024) #include <stdarg.h> +#include <stddef.h> #include <sys/types.h> typedef char *sds; struct sdshdr { - int len; - int free; + size_t len; + size_t free; char buf[]; }; static inline struct sdshdr * sdsheader(const sds s) { - return s - (sizeof (struct sdshdr)); + /* The sdshdr pointer has a different alignment than the original char + * pointer, so cast it through a void pointer to silence the warning. */ + return (void *)(s - (sizeof (struct sdshdr))); } static inline size_t sdslen(const sds s) { @@ -76,12 +79,12 @@ sds sdscatprintf(sds s, const char *fmt, ...); #endif void sdstrim(sds s, const char *cset); -void sdsrange(sds s, int start, int end); +void sdsrange(sds s, ptrdiff_t start, ptrdiff_t end); void sdsupdatelen(sds s); void sdsclear(sds s); int sdscmp(const sds s1, const sds s2); -sds *sdssplitlen(const char *s, int len, const char *sep, int seplen, int *count); -void sdsfreesplitres(sds *tokens, int count); +sds *sdssplitlen(const char *s, size_t len, const char *sep, size_t seplen, size_t *count); +void sdsfreesplitres(sds *tokens, size_t count); void sdstolower(sds s); void sdstoupper(sds s); sds sdsfromlonglong(long long value); @@ -93,7 +96,7 @@ sds sdsjoinsds(sds *argv, int argc, const char *sep, size_t seplen); /* Low level functions exposed to the user API */ sds sdsMakeRoomFor(sds s, size_t addlen); -void sdsIncrLen(sds s, int incr); +void sdsIncrLen(sds s, size_t incr); sds sdsRemoveFreeSpace(sds s); size_t sdsAllocSize(sds s); |