gzdoom-gles/libraries/lzma/C/7zBuf.c

37 lines
530 B
C
Raw Normal View History

2016-03-01 15:47:10 +00:00
/* 7zBuf.c -- Byte Buffer
2018-01-08 12:00:01 +00:00
2017-04-03 : Igor Pavlov : Public domain */
2016-03-01 15:47:10 +00:00
#include "Precomp.h"
#include "7zBuf.h"
void Buf_Init(CBuf *p)
{
p->data = 0;
p->size = 0;
}
2018-01-08 12:00:01 +00:00
int Buf_Create(CBuf *p, size_t size, ISzAllocPtr alloc)
2016-03-01 15:47:10 +00:00
{
p->size = 0;
if (size == 0)
{
p->data = 0;
return 1;
}
2018-01-08 12:00:01 +00:00
p->data = (Byte *)ISzAlloc_Alloc(alloc, size);
if (p->data)
2016-03-01 15:47:10 +00:00
{
p->size = size;
return 1;
}
return 0;
}
2018-01-08 12:00:01 +00:00
void Buf_Free(CBuf *p, ISzAllocPtr alloc)
2016-03-01 15:47:10 +00:00
{
2018-01-08 12:00:01 +00:00
ISzAlloc_Free(alloc, p->data);
2016-03-01 15:47:10 +00:00
p->data = 0;
p->size = 0;
}