From: Sebastian Harl Date: Thu, 7 Nov 2013 06:48:59 +0000 (+0100) Subject: utils strbuf: Advance buffer position in sdb_strbuf_read(). X-Git-Tag: sysdb-0.1.0~336^2~18 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a6753b33e70f0934d4b34b19366eddda56f05d9c;p=sysdb.git utils strbuf: Advance buffer position in sdb_strbuf_read(). --- diff --git a/src/utils/strbuf.c b/src/utils/strbuf.c index 2b64480..4d8fc8b 100644 --- a/src/utils/strbuf.c +++ b/src/utils/strbuf.c @@ -238,13 +238,18 @@ sdb_strbuf_memcpy(sdb_strbuf_t *strbuf, const void *data, size_t n) ssize_t sdb_strbuf_read(sdb_strbuf_t *strbuf, int fd, size_t n) { + ssize_t ret; + if (! strbuf) return -1; if (strbuf_resize(strbuf, strbuf->pos + n + 1)) return -1; - return read(fd, strbuf->string + strbuf->pos, n); + ret = read(fd, strbuf->string + strbuf->pos, n); + if (ret > 0) + strbuf->pos += (size_t)ret; + return ret; } /* sdb_strbuf_read */ ssize_t