Mercurial > hg > dmlib
diff src/dmgrowbuf.h @ 1747:5e928618fdc8
Change DMGrowBuf API somewhat and implement more copy operations.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 11 Jun 2018 13:57:07 +0300 |
parents | 7eb00206b36d |
children | 3d4bb20f6739 |
line wrap: on
line diff
--- a/src/dmgrowbuf.h Sun Jun 10 20:01:03 2018 +0300 +++ b/src/dmgrowbuf.h Mon Jun 11 13:57:07 2018 +0300 @@ -28,7 +28,6 @@ mingrow; // Minimum amount of bytes the allocation size grows by BOOL - allocated, // TRUE if this structure itself has been allocated and can be freed, FALSE if static backwards, // TRUE if the buffer grows backwards (e.g. "offs" moves backwards) literal, // TRUE if dmGrowBufPut*() functions stores data "literally" in backwards mode is_const; // TRUE will cause any reallocs etc. modifications to fail @@ -37,15 +36,13 @@ int dmGrowBufInit(DMGrowBuf *buf); int dmGrowBufAlloc(DMGrowBuf *buf, const size_t initial, const size_t mingrow); -int dmGrowBufNew(DMGrowBuf **pbuf, const size_t initial, const size_t mingrow); void dmGrowBufFree(DMGrowBuf *buf); +DMGrowBuf * dmGrowBufCopy(DMGrowBuf *dst, const DMGrowBuf *src, const size_t enlarge); +DMGrowBuf * dmGrowBufCopyOffs(DMGrowBuf *dst, const DMGrowBuf *src, const size_t offs, const size_t enlarge); DMGrowBuf * dmGrowBufConstCopy(DMGrowBuf *dst, const DMGrowBuf *src); -DMGrowBuf * dmGrowBufCreateFrom(DMGrowBuf *buf, Uint8 *data, size_t len); -static inline DMGrowBuf * dmGrowBufCreateFromOffs(DMGrowBuf *dst, const DMGrowBuf *src, const size_t offs) -{ - return dmGrowBufCreateFrom(dst, src->data + offs, src->len - offs); -} +DMGrowBuf * dmGrowBufConstCopyOffs(DMGrowBuf *dst, const DMGrowBuf *src, const size_t offs); +DMGrowBuf * dmGrowBufConstCreateFrom(DMGrowBuf *buf, Uint8 *data, size_t len); BOOL dmGrowBufGrow(DMGrowBuf *buf, const size_t amount);