aboutsummaryrefslogtreecommitdiffstats
path: root/src/sds.c
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2015-01-18 15:41:09 +0100
committerJohannes Löthberg <johannes@kyriasis.com>2015-01-19 00:25:40 +0100
commit459d2cb217e1af053f08d7e30a92b1b6bf61a90a (patch)
tree9a2fb690e0501f761ddfd30c5081313e94804e28 /src/sds.c
parenta3d3b21dbdad912fcca74ba2263d007c764b9ea3 (diff)
downloadsds-459d2cb217e1af053f08d7e30a92b1b6bf61a90a.tar.xz
sdsrange: change start/end args to ptrdiff_t
An sds string can hold a much bigger value than an int can hold, but since size_t is unsigned it can’t be used for this function. Using ptrdiff_t limits the function to work on roughly 1 Exabyte long strings, but if you need to work with longer ones you probably will have your custom string library already.
Diffstat (limited to 'src/sds.c')
-rw-r--r--src/sds.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/sds.c b/src/sds.c
index 0e62f31..96a6c4c 100644
--- a/src/sds.c
+++ b/src/sds.c
@@ -27,6 +27,7 @@
#include <assert.h>
#include <ctype.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -388,7 +389,7 @@ void sdstrim(sds s, const char *cset) {
* s = sdsnew("Hello World");
* sdsrange(s,1,-1); => "ello World"
*/
-void sdsrange(sds s, int start, int end) {
+void sdsrange(sds s, ptrdiff_t start, ptrdiff_t end) {
struct sdshdr *sh = sdsheader(s);
size_t newlen, len = sdslen(s);