Commit 11425c89 authored by antirez's avatar antirez
Browse files

SDS: sdsjoinsds() call ported from antirez/sds fork.

parent 6b836b6b
...@@ -1075,6 +1075,18 @@ sds sdsjoin(char **argv, int argc, char *sep) { ...@@ -1075,6 +1075,18 @@ sds sdsjoin(char **argv, int argc, char *sep) {
return join; return join;
} }
/* Like sdsjoin, but joins an array of SDS strings. */
sds sdsjoinsds(sds *argv, int argc, const char *sep, size_t seplen) {
sds join = sdsempty();
int j;
for (j = 0; j < argc; j++) {
join = sdscatsds(join, argv[j]);
if (j != argc-1) join = sdscatlen(join,sep,seplen);
}
return join;
}
#if defined(REDIS_TEST) || defined(SDS_TEST_MAIN) #if defined(REDIS_TEST) || defined(SDS_TEST_MAIN)
#include <stdio.h> #include <stdio.h>
#include "testhelp.h" #include "testhelp.h"
......
...@@ -247,6 +247,7 @@ sds sdscatrepr(sds s, const char *p, size_t len); ...@@ -247,6 +247,7 @@ sds sdscatrepr(sds s, const char *p, size_t len);
sds *sdssplitargs(const char *line, int *argc); sds *sdssplitargs(const char *line, int *argc);
sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen); sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen);
sds sdsjoin(char **argv, int argc, char *sep); sds sdsjoin(char **argv, int argc, char *sep);
sds sdsjoinsds(sds *argv, int argc, const char *sep, size_t seplen);
/* Low level functions exposed to the user API */ /* Low level functions exposed to the user API */
sds sdsMakeRoomFor(sds s, size_t addlen); sds sdsMakeRoomFor(sds s, size_t addlen);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment