diff options
author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2021-12-27 00:00:00 +0000 |
---|---|---|
committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2022-03-18 15:35:13 +0500 |
commit | f19f813537c7aea1c20749c914e756b54a9c3cf5 (patch) | |
tree | 816ba62ca7c0fa19f2eb46d9e9d6f7dd7c3a744d /C/7zBuf.c | |
parent | 98e06a519b63b81986abe76d28887f6984a7732b (diff) | |
download | 7zip-f19f813537c7aea1c20749c914e756b54a9c3cf5.tar.gz 7zip-f19f813537c7aea1c20749c914e756b54a9c3cf5.tar.bz2 7zip-f19f813537c7aea1c20749c914e756b54a9c3cf5.zip |
'21.07'21.07
Diffstat (limited to 'C/7zBuf.c')
-rw-r--r-- | C/7zBuf.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/C/7zBuf.c b/C/7zBuf.c new file mode 100644 index 0000000..8865c32 --- /dev/null +++ b/C/7zBuf.c | |||
@@ -0,0 +1,36 @@ | |||
1 | /* 7zBuf.c -- Byte Buffer | ||
2 | 2017-04-03 : Igor Pavlov : Public domain */ | ||
3 | |||
4 | #include "Precomp.h" | ||
5 | |||
6 | #include "7zBuf.h" | ||
7 | |||
8 | void Buf_Init(CBuf *p) | ||
9 | { | ||
10 | p->data = 0; | ||
11 | p->size = 0; | ||
12 | } | ||
13 | |||
14 | int Buf_Create(CBuf *p, size_t size, ISzAllocPtr alloc) | ||
15 | { | ||
16 | p->size = 0; | ||
17 | if (size == 0) | ||
18 | { | ||
19 | p->data = 0; | ||
20 | return 1; | ||
21 | } | ||
22 | p->data = (Byte *)ISzAlloc_Alloc(alloc, size); | ||
23 | if (p->data) | ||
24 | { | ||
25 | p->size = size; | ||
26 | return 1; | ||
27 | } | ||
28 | return 0; | ||
29 | } | ||
30 | |||
31 | void Buf_Free(CBuf *p, ISzAllocPtr alloc) | ||
32 | { | ||
33 | ISzAlloc_Free(alloc, p->data); | ||
34 | p->data = 0; | ||
35 | p->size = 0; | ||
36 | } | ||