diff options
author | Eric Wong <e@80x24.org> | 2015-08-23 20:49:52 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-08-23 20:49:52 +0000 |
commit | 45bfce46d24db91d25b85a5115c2b41d4a1484fc (patch) | |
tree | 7db4adb0230e585fbeae52fa0b77ef603e581c9c /trywrite.c | |
parent | 7754b9ffc1b496170498f78fd2f05409dd0fb962 (diff) | |
download | cmogstored-45bfce46d24db91d25b85a5115c2b41d4a1484fc.tar.gz |
This also makes trywrite OOM-aware and will simulate a write error on allocation.
Diffstat (limited to 'trywrite.c')
-rw-r--r-- | trywrite.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -12,10 +12,14 @@ struct mog_wbuf { static void * wbuf_newv(size_t total, struct iovec *iov, int iovcnt) { - struct mog_wbuf *wbuf = xmalloc(sizeof(struct mog_wbuf) + total); - void *dst = wbuf->buf; + struct mog_wbuf *wbuf = malloc(sizeof(struct mog_wbuf) + total); + void *dst; int i; + if (!wbuf) return MOG_WR_ERROR; + + dst = wbuf->buf; + wbuf->len = total; wbuf->off = 0; |