all repos — mgba @ b2d406a411b31acce5bbf0246af32a80c22ca834

mGBA Game Boy Advance Emulator

src/third-party/lzma/7zBuf.c (view raw)

 1/* 7zBuf.c -- Byte Buffer
 22017-04-03 : Igor Pavlov : Public domain */
 3
 4#include "Precomp.h"
 5
 6#include "7zBuf.h"
 7
 8void Buf_Init(CBuf *p)
 9{
10  p->data = 0;
11  p->size = 0;
12}
13
14int 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
31void Buf_Free(CBuf *p, ISzAllocPtr alloc)
32{
33  ISzAlloc_Free(alloc, p->data);
34  p->data = 0;
35  p->size = 0;
36}