Code

utils strbuf: Advance buffer position in sdb_strbuf_read().
authorSebastian Harl <sh@tokkee.org>
Thu, 7 Nov 2013 06:48:59 +0000 (07:48 +0100)
committerSebastian Harl <sh@tokkee.org>
Thu, 7 Nov 2013 06:48:59 +0000 (07:48 +0100)
src/utils/strbuf.c

index 2b64480c55fc5960c816f83ef3a6b3bf626c1faf..4d8fc8b91ba234df10edd8d15d552169bcbf9930 100644 (file)
@@ -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