aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2015-01-17 23:58:43 +0100
committerJohannes Löthberg <johannes@kyriasis.com>2015-01-17 23:58:43 +0100
commit5f4379bfe7fcd17216160e945b66d72002b2b0b2 (patch)
tree49a1789ea081762a384de53fb8f5cb7c5519092b /src
parent9d24a269ddee4ac786119ab3385c97d7e27d0117 (diff)
downloadsds-5f4379bfe7fcd17216160e945b66d72002b2b0b2.tar.xz
sds.c: All if statements should be braced
Diffstat (limited to 'src')
-rw-r--r--src/sds.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/sds.c b/src/sds.c
index aa326a2..6573634 100644
--- a/src/sds.c
+++ b/src/sds.c
@@ -56,8 +56,9 @@ sds sdsnewlen(const void *init, size_t initlen) {
if (sh == NULL) return NULL;
sh->len = initlen;
sh->free = 0;
- if (initlen && init)
+ if (initlen && init) {
memcpy(sh->buf, init, initlen);
+ }
sh->buf[initlen] = '\0';
return (char*)sh->buf;
}
@@ -132,10 +133,11 @@ sds sdsMakeRoomFor(sds s, size_t addlen) {
len = sdslen(s);
sh = sdsheader(s);
newlen = (len+addlen);
- if (newlen < SDS_MAX_PREALLOC)
+ if (newlen < SDS_MAX_PREALLOC) {
newlen *= 2;
- else
+ } else {
newlen += SDS_MAX_PREALLOC;
+ }
newsh = realloc(sh, sizeof(struct sdshdr)+newlen+1);
if (newsh == NULL) return NULL;
@@ -560,11 +562,12 @@ sds sdscatrepr(sds s, const char *p, size_t len) {
case '\a': s = sdscatlen(s,"\\a",2); break;
case '\b': s = sdscatlen(s,"\\b",2); break;
default:
- if (isprint(*p))
+ if (isprint(*p)) {
s = sdscatprintf(s,"%c",*p);
- else
+ } else {
s = sdscatprintf(s,"\\x%02x",(unsigned char)*p);
break;
+ }
}
p++;
}