Don't udpate LastOverSpeedTick when using aqua_speed
[ryzomcore.git] / nel / 3rdparty / seven_zip / 7zBuf2.c
blob208347416542752abdacbbd31b4a85e4746f2f5a
1 /* 7zBuf2.c -- Byte Buffer
2 2017-04-03 : Igor Pavlov : Public domain */
4 #include "Precomp.h"
6 #include <string.h>
8 #include "7zBuf.h"
10 void DynBuf_Construct(CDynBuf *p)
12 p->data = 0;
13 p->size = 0;
14 p->pos = 0;
17 void DynBuf_SeekToBeg(CDynBuf *p)
19 p->pos = 0;
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;
27 Byte *data;
28 newSize += newSize / 4;
29 data = (Byte *)ISzAlloc_Alloc(alloc, newSize);
30 if (!data)
31 return 0;
32 p->size = newSize;
33 if (p->pos != 0)
34 memcpy(data, p->data, p->pos);
35 ISzAlloc_Free(alloc, p->data);
36 p->data = data;
38 if (size != 0)
40 memcpy(p->data + p->pos, buf, size);
41 p->pos += size;
43 return 1;
46 void DynBuf_Free(CDynBuf *p, ISzAllocPtr alloc)
48 ISzAlloc_Free(alloc, p->data);
49 p->data = 0;
50 p->size = 0;
51 p->pos = 0;