equal
deleted
inserted
replaced
|
1 /* 7zBuffer.c */ |
|
2 |
|
3 #include "7zBuffer.h" |
|
4 #include "7zAlloc.h" |
|
5 |
|
6 void SzByteBufferInit(CSzByteBuffer *buffer) |
|
7 { |
|
8 buffer->Capacity = 0; |
|
9 buffer->Items = 0; |
|
10 } |
|
11 |
|
12 int SzByteBufferCreate(CSzByteBuffer *buffer, size_t newCapacity, void * (*allocFunc)(size_t size)) |
|
13 { |
|
14 buffer->Capacity = newCapacity; |
|
15 if (newCapacity == 0) |
|
16 { |
|
17 buffer->Items = 0; |
|
18 return 1; |
|
19 } |
|
20 buffer->Items = (Byte *)allocFunc(newCapacity); |
|
21 return (buffer->Items != 0); |
|
22 } |
|
23 |
|
24 void SzByteBufferFree(CSzByteBuffer *buffer, void (*freeFunc)(void *)) |
|
25 { |
|
26 freeFunc(buffer->Items); |
|
27 buffer->Items = 0; |
|
28 buffer->Capacity = 0; |
|
29 } |