misc/libphysfs/lzma/C/Archive/7z/7zBuffer.c
changeset 13904 99b265e0d1d0
parent 13903 5f819b90d479
child 13905 b172a5d40eee
equal deleted inserted replaced
13903:5f819b90d479 13904:99b265e0d1d0
     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 }