comparison src/dmgrowbuf.c @ 1694:e568535e1a96

Backed out changeset 9611ecd2c4fb
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 05 Jun 2018 11:03:17 +0300
parents ce8d4552ffd5
children 1036b0dcccb5
comparison
equal deleted inserted replaced
1693:ce8d4552ffd5 1694:e568535e1a96
13 #else 13 #else
14 # define DM_DBG(...) do { } while (0) 14 # define DM_DBG(...) do { } while (0)
15 #endif 15 #endif
16 16
17 17
18 int dmGrowBufInit(DMGrowBuf *buf)
19 {
20 DM_DBG("dmGrowBufInit(%p)\n", buf);
21
22 if (buf == NULL)
23 return DMERR_NULLPTR;
24
25 memset(buf, 0, sizeof(DMGrowBuf));
26
27 return DMERR_OK;
28 }
29
30
18 int dmGrowBufAlloc(DMGrowBuf *buf, const size_t initial, const size_t mingrow) 31 int dmGrowBufAlloc(DMGrowBuf *buf, const size_t initial, const size_t mingrow)
19 { 32 {
33 int res;
34
20 DM_DBG("dmGrowBufAlloc(%p, %" DM_PRIu_SIZE_T ", %" DM_PRIu_SIZE_T ")\n", 35 DM_DBG("dmGrowBufAlloc(%p, %" DM_PRIu_SIZE_T ", %" DM_PRIu_SIZE_T ")\n",
21 buf, initial, mingrow); 36 buf, initial, mingrow);
22 37
23 if (buf == NULL) 38 if ((res = dmGrowBufInit(buf)) != DMERR_OK)
24 return DMERR_NULLPTR; 39 return res;
25
26 memset(buf, 0, sizeof(DMGrowBuf));
27 40
28 buf->len = 0; 41 buf->len = 0;
29 buf->offs = 0; 42 buf->offs = 0;
30 buf->size = initial; 43 buf->size = initial;
31 buf->mingrow = mingrow; 44 buf->mingrow = mingrow;