#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "allheaders.h"
Функции | |
BBUFFER * | bbufferCreate (l_uint8 *indata, l_int32 nalloc) |
void | bbufferDestroy (BBUFFER **pbb) |
l_uint8 * | bbufferDestroyAndSaveData (BBUFFER **pbb, l_int32 *pnbytes) |
l_int32 | bbufferRead (BBUFFER *bb, l_uint8 *src, l_int32 nbytes) |
l_int32 | bbufferReadStream (BBUFFER *bb, FILE *fp, l_int32 nbytes) |
l_int32 | bbufferExtendArray (BBUFFER *bb, l_int32 nbytes) |
l_int32 | bbufferWrite (BBUFFER *bb, l_uint8 *dest, l_int32 nbytes, l_int32 *pnout) |
l_int32 | bbufferWriteStream (BBUFFER *bb, FILE *fp, l_int32 nbytes, l_int32 *pnout) |
l_int32 | bbufferBytesToWrite (BBUFFER *bb, l_int32 *pnbytes) |
Переменные | |
static const l_int32 | INITIAL_BUFFER_ARRAYSIZE = 1024 |
Input: bbuffer &nbytes (<return>) Return: 0 if OK; 1 on error
Input: buffer address in memory (<optional>) size of byte array to be alloc'd (0 for default) Return: bbuffer, or null on error
Notes: (1) If a buffer address is given, you should read all the data in. (2) Allocates a bbuffer with associated byte array of the given size. If a buffer address is given, it then reads the number of bytes into the byte array.
void bbufferDestroy | ( | BBUFFER ** | pbb | ) |
Input: &bbuffer (<to be="" nulled>="">) Return: void
Notes: (1) Destroys the byte array in the bbuffer and then the bbuffer; then nulls the contents of the input ptr.
Input: &bbuffer (<to be="" nulled>="">) &nbytes (<return> number of bytes saved in array) Return: barray (newly allocated array of data)
Notes: (1) Copies data to newly allocated array; then destroys the bbuffer.
Input: bbuffer nbytes (number of bytes to extend array size) Return: 0 if OK, 1 on error
Notes: (1) reallocNew() copies all bb->nalloc bytes, even though only bb->n are data.
Input: bbuffer src (source memory buffer from which bytes are read) nbytes (bytes to be read) Return: 0 if OK, 1 on error
Notes: (1) For a read after write, first remove the written bytes by shifting the unwritten bytes in the array, then check if there is enough room to add the new bytes. If not, realloc with bbufferExpandArray(), resulting in a second writing of the unwritten bytes. While less efficient, this is simpler than making a special case of reallocNew().
Input: bbuffer fp (source stream from which bytes are read) nbytes (bytes to be read) Return: 0 if OK, 1 on error
Input: bbuffer dest (dest memory buffer to which bytes are written) nbytes (bytes requested to be written) &nout (<return> bytes actually written) Return: 0 if OK, 1 on error
Input: bbuffer fp (dest stream to which bytes are written) nbytes (bytes requested to be written) &nout (<return> bytes actually written) Return: 0 if OK, 1 on error
const l_int32 INITIAL_BUFFER_ARRAYSIZE = 1024 [static] |