Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
527 B

  1. /* 7zBuf.c -- Byte Buffer
  2. 2013-01-21 : Igor Pavlov : Public domain */
  3. #include "Precomp.h"
  4. #include "7zBuf.h"
  5. void Buf_Init(CBuf *p)
  6. {
  7. p->data = 0;
  8. p->size = 0;
  9. }
  10. int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc)
  11. {
  12. p->size = 0;
  13. if (size == 0)
  14. {
  15. p->data = 0;
  16. return 1;
  17. }
  18. p->data = (Byte *)alloc->Alloc(alloc, size);
  19. if (p->data != 0)
  20. {
  21. p->size = size;
  22. return 1;
  23. }
  24. return 0;
  25. }
  26. void Buf_Free(CBuf *p, ISzAlloc *alloc)
  27. {
  28. alloc->Free(alloc, p->data);
  29. p->data = 0;
  30. p->size = 0;
  31. }