diff options
author | Johannes Löthberg <johannes@kyriasis.com> | 2015-01-17 23:58:43 +0100 |
---|---|---|
committer | Johannes Löthberg <johannes@kyriasis.com> | 2015-01-17 23:58:43 +0100 |
commit | 5f4379bfe7fcd17216160e945b66d72002b2b0b2 (patch) | |
tree | 49a1789ea081762a384de53fb8f5cb7c5519092b /src | |
parent | 9d24a269ddee4ac786119ab3385c97d7e27d0117 (diff) | |
download | sds-5f4379bfe7fcd17216160e945b66d72002b2b0b2.tar.xz |
sds.c: All if statements should be braced
Diffstat (limited to 'src')
-rw-r--r-- | src/sds.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -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++; } |