Файл src/bbuffer.c

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "allheaders.h"

Функции

BBUFFERbbufferCreate (l_uint8 *indata, l_int32 nalloc)
void bbufferDestroy (BBUFFER **pbb)
l_uint8bbufferDestroyAndSaveData (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

Функции

l_int32 bbufferBytesToWrite ( BBUFFER bb,
l_int32 pnbytes 
)

bbufferBytesToWrite()

Input: bbuffer &nbytes (<return>) Return: 0 if OK; 1 on error

BBUFFER* bbufferCreate ( l_uint8 indata,
l_int32  nalloc 
)

bbufferCreate()

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  ) 

bbufferDestroy()

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.

l_uint8* bbufferDestroyAndSaveData ( BBUFFER **  pbb,
l_int32 pnbytes 
)

bbufferDestroyAndSaveData()

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.

l_int32 bbufferExtendArray ( BBUFFER bb,
l_int32  nbytes 
)

bbufferExtendArray()

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.

l_int32 bbufferRead ( BBUFFER bb,
l_uint8 src,
l_int32  nbytes 
)

bbufferRead()

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().

l_int32 bbufferReadStream ( BBUFFER bb,
FILE *  fp,
l_int32  nbytes 
)

bbufferReadStream()

Input: bbuffer fp (source stream from which bytes are read) nbytes (bytes to be read) Return: 0 if OK, 1 on error

l_int32 bbufferWrite ( BBUFFER bb,
l_uint8 dest,
l_int32  nbytes,
l_int32 pnout 
)

bbufferWrite()

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

l_int32 bbufferWriteStream ( BBUFFER bb,
FILE *  fp,
l_int32  nbytes,
l_int32 pnout 
)

bbufferWriteStream()

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]


Документация по Leptonica. Последние изменения: Fri Aug 7 20:31:35 2009. Создано системой  doxygen 1.5.9