![]() |
Leptonica
1.73
Image processing and image analysis suite
|
#include <string.h>#include "allheaders.h"Go to the source code of this file.
Functions | |
| static l_int32 | l_byteaExtendArrayToSize (L_BYTEA *ba, size_t size) |
| L_BYTEA * | l_byteaCreate (size_t nbytes) |
| L_BYTEA * | l_byteaInitFromMem (l_uint8 *data, size_t size) |
| L_BYTEA * | l_byteaInitFromFile (const char *fname) |
| L_BYTEA * | l_byteaInitFromStream (FILE *fp) |
| L_BYTEA * | l_byteaCopy (L_BYTEA *bas, l_int32 copyflag) |
| void | l_byteaDestroy (L_BYTEA **pba) |
| size_t | l_byteaGetSize (L_BYTEA *ba) |
| l_uint8 * | l_byteaGetData (L_BYTEA *ba, size_t *psize) |
| l_uint8 * | l_byteaCopyData (L_BYTEA *ba, size_t *psize) |
| l_int32 | l_byteaAppendData (L_BYTEA *ba, l_uint8 *newdata, size_t newbytes) |
| l_int32 | l_byteaAppendString (L_BYTEA *ba, char *str) |
| l_int32 | l_byteaJoin (L_BYTEA *ba1, L_BYTEA **pba2) |
| l_int32 | l_byteaSplit (L_BYTEA *ba1, size_t splitloc, L_BYTEA **pba2) |
| l_int32 | l_byteaFindEachSequence (L_BYTEA *ba, l_uint8 *sequence, l_int32 seqlen, L_DNA **pda) |
| l_int32 | l_byteaWrite (const char *fname, L_BYTEA *ba, size_t startloc, size_t endloc) |
| l_int32 | l_byteaWriteStream (FILE *fp, L_BYTEA *ba, size_t startloc, size_t endloc) |
Variables | |
| static const l_int32 | INITIAL_ARRAYSIZE = 200 |
Functions for handling byte arrays, in analogy with C++ 'strings'
Creation, copy, clone, destruction
L_BYTEA *l_byteaCreate()
L_BYTEA *l_byteaInitFromMem()
L_BYTEA *l_byteaInitFromFile()
L_BYTEA *l_byteaInitFromStream()
L_BYTEA *l_byteaCopy()
L_BYTEA *l_byteaClone()
void l_byteaDestroy() Accessors
size_t l_byteaGetSize()
l_uint8 *l_byteaGetData()
l_uint8 *l_byteaCopyData() Appending
l_int32 l_byteaAppendData()
l_int32 l_byteaAppendString()
static l_int32 l_byteaExtendArrayToSize() Join/Split
l_int32 l_byteaJoin()
l_int32 l_byteaSplit() Search
l_int32 l_byteaFindEachSequence() Output to file
l_int32 l_byteaWrite()
l_int32 l_byteaWriteStream()The internal data array is always null-terminated, for ease of use in the event that it is an ascii string without null bytes.
Definition in file bytearray.c.
| l_int32 l_byteaAppendData | ( | L_BYTEA * | ba, |
| l_uint8 * | newdata, | ||
| size_t | newbytes | ||
| ) |
| [in] | ba | |
| [in] | newdata | byte array to be appended |
| [in] | newbytes | size of data array |
Definition at line 363 of file bytearray.c.
References L_Bytea::data, l_byteaExtendArrayToSize(), l_byteaGetSize(), L_Bytea::nalloc, and L_Bytea::size.
Referenced by l_byteaJoin(), and substituteObjectNumbers().
| l_int32 l_byteaAppendString | ( | L_BYTEA * | ba, |
| char * | str | ||
| ) |
| [in] | ba | |
| [in] | str | null-terminated string to be appended |
Definition at line 396 of file bytearray.c.
References L_Bytea::data, l_byteaExtendArrayToSize(), l_byteaGetSize(), L_Bytea::nalloc, and L_Bytea::size.
Referenced by pathJoin(), and substituteObjectNumbers().
| [in] | bas | source lba |
| [in] | copyflag | L_COPY, L_CLONE |
Notes:
(1) If cloning, up the refcount and return a ptr to bas.
Definition at line 213 of file bytearray.c.
References L_Bytea::data, l_byteaInitFromMem(), L_CLONE, L_Bytea::refcount, and L_Bytea::size.
| l_uint8* l_byteaCopyData | ( | L_BYTEA * | ba, |
| size_t * | psize | ||
| ) |
| [in] | ba | |
| [out] | psize | size of data in lba |
Notes:
(1) The returned data is owned by the caller. The input ba
still owns the original data array.
Definition at line 333 of file bytearray.c.
References l_binaryCopy(), and l_byteaGetData().
| L_BYTEA* l_byteaCreate | ( | size_t | nbytes | ) |
| [in] | nbytes | determines initial size of data array |
Notes:
(1) The allocated array is n + 1 bytes. This allows room
for null termination.
Definition at line 93 of file bytearray.c.
Referenced by l_byteaInitFromMem(), l_byteaInitFromStream(), pathJoin(), and substituteObjectNumbers().
| void l_byteaDestroy | ( | L_BYTEA ** | pba | ) |
| [in,out] | pba | will be set to null before returning |
Notes:
(1) Decrements the ref count and, if 0, destroys the lba.
(2) Always nulls the input ptr.
(3) If the data has been previously removed, the lba will
have been nulled, so this will do nothing.
Definition at line 245 of file bytearray.c.
References L_Bytea::data, and L_Bytea::refcount.
Referenced by convertSegmentedFilesToPdf(), l_byteaJoin(), pixaConvertToPdfData(), ptraConcatenatePdfToData(), saConcatenatePdfToData(), saConvertFilesToPdfData(), and saConvertUnscaledFilesToPdfData().
|
static |
| [in] | ba | |
| [in] | size | new size of lba data array |
Definition at line 429 of file bytearray.c.
References L_Bytea::data, L_Bytea::nalloc, and reallocNew().
Referenced by l_byteaAppendData(), and l_byteaAppendString().
| [in] | ba | |
| [in] | sequence | subarray of bytes to find in data |
| [in] | seqlen | length of sequence, in bytes |
| [out] | pda | byte positions of each occurrence of sequence |
Definition at line 540 of file bytearray.c.
References arrayFindEachSequence(), and l_byteaGetData().
Referenced by parseTrailerPdf().
| l_uint8* l_byteaGetData | ( | L_BYTEA * | ba, |
| size_t * | psize | ||
| ) |
| [in] | ba | |
| [out] | psize | size of data in lba |
Notes:
(1) The returned ptr is owned by ba. Do not free it!
Definition at line 304 of file bytearray.c.
References L_Bytea::data, and L_Bytea::size.
Referenced by l_byteaCopyData(), l_byteaFindEachSequence(), l_byteaJoin(), l_byteaSplit(), l_byteaWriteStream(), parseTrailerPdf(), and substituteObjectNumbers().
| size_t l_byteaGetSize | ( | L_BYTEA * | ba | ) |
| [in] | ba |
Definition at line 281 of file bytearray.c.
References L_Bytea::size.
Referenced by l_byteaAppendData(), and l_byteaAppendString().
| L_BYTEA* l_byteaInitFromFile | ( | const char * | fname | ) |
| [in] | fname |
Definition at line 149 of file bytearray.c.
References fopenReadStream(), and l_byteaInitFromStream().
Referenced by saConcatenatePdfToData().
| L_BYTEA* l_byteaInitFromMem | ( | l_uint8 * | data, |
| size_t | size | ||
| ) |
| [in] | data | to be copied to the array |
| [in] | size | amount of data |
Definition at line 122 of file bytearray.c.
References L_Bytea::data, l_byteaCreate(), and L_Bytea::size.
Referenced by convertSegmentedFilesToPdf(), l_byteaCopy(), l_byteaSplit(), pixaConvertToPdfData(), saConvertFilesToPdfData(), and saConvertUnscaledFilesToPdfData().
| L_BYTEA* l_byteaInitFromStream | ( | FILE * | fp | ) |
| [in] | fp | file stream |
Definition at line 176 of file bytearray.c.
References L_Bytea::data, l_binaryReadStream(), l_byteaCreate(), and L_Bytea::size.
Referenced by l_byteaInitFromFile().
| [in] | ba1 | |
| [in,out] | pba2 | data array is added to the one in ba1, and then ba2 is destroyed |
Notes:
(1) It is a no-op, not an error, for ba2 to be null.
Definition at line 465 of file bytearray.c.
References l_byteaAppendData(), l_byteaDestroy(), and l_byteaGetData().
| [in] | ba1 | lba to split; array bytes nulled beyond the split loc |
| [in] | splitloc | location in ba1 to split; ba2 begins there |
| [out] | pba2 | with data starting at splitloc |
Definition at line 497 of file bytearray.c.
References l_byteaGetData(), l_byteaInitFromMem(), and L_Bytea::size.
| l_int32 l_byteaWrite | ( | const char * | fname, |
| L_BYTEA * | ba, | ||
| size_t | startloc, | ||
| size_t | endloc | ||
| ) |
| [in] | fname | output file |
| [in] | ba | |
| [in] | startloc | first byte to output |
| [in] | endloc | last byte to output; use 0 to write to the end of the data array |
Definition at line 578 of file bytearray.c.
References fopenWriteStream(), and l_byteaWriteStream().
| l_int32 l_byteaWriteStream | ( | FILE * | fp, |
| L_BYTEA * | ba, | ||
| size_t | startloc, | ||
| size_t | endloc | ||
| ) |
| [in] | fp | file stream opened for binary write |
| [in] | ba | |
| [in] | startloc | first byte to output |
| [in] | endloc | last byte to output; use 0 to write to the end of the data array |
Definition at line 612 of file bytearray.c.
References l_byteaGetData().
Referenced by l_byteaWrite().
1.8.14