1 /* 7zBuf2.c -- Byte Buffer
2 2017-04-03 : Igor Pavlov : Public domain */
10 void DynBuf_Construct(CDynBuf
*p
)
17 void DynBuf_SeekToBeg(CDynBuf
*p
)
22 int DynBuf_Write(CDynBuf
*p
, const Byte
*buf
, size_t size
, ISzAllocPtr alloc
)
24 if (size
> p
->size
- p
->pos
)
26 size_t newSize
= p
->pos
+ size
;
28 newSize
+= newSize
/ 4;
29 data
= (Byte
*)ISzAlloc_Alloc(alloc
, newSize
);
34 memcpy(data
, p
->data
, p
->pos
);
35 ISzAlloc_Free(alloc
, p
->data
);
40 memcpy(p
->data
+ p
->pos
, buf
, size
);
46 void DynBuf_Free(CDynBuf
*p
, ISzAllocPtr alloc
)
48 ISzAlloc_Free(alloc
, p
->data
);