![]() |
Leptonica
1.82.0
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 (const 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_ok | l_byteaAppendData (L_BYTEA *ba, const l_uint8 *newdata, size_t newbytes) |
l_ok | l_byteaAppendString (L_BYTEA *ba, const char *str) |
l_ok | l_byteaJoin (L_BYTEA *ba1, L_BYTEA **pba2) |
l_ok | l_byteaSplit (L_BYTEA *ba1, size_t splitloc, L_BYTEA **pba2) |
l_ok | l_byteaFindEachSequence (L_BYTEA *ba, const l_uint8 *sequence, size_t seqlen, L_DNA **pda) |
l_ok | l_byteaWrite (const char *fname, L_BYTEA *ba, size_t startloc, size_t nbytes) |
l_ok | l_byteaWriteStream (FILE *fp, L_BYTEA *ba, size_t startloc, size_t nbytes) |
Variables | |
static const l_uint32 | MaxArraySize = 1000000000 |
static const l_int32 | InitialArraySize = 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() 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_ok l_byteaAppendData | ( | L_BYTEA * | ba, |
const l_uint8 * | newdata, | ||
size_t | newbytes | ||
) |
[in] | ba | |
[in] | newdata | byte array to be appended |
[in] | newbytes | size of data array |
Definition at line 366 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_ok l_byteaAppendString | ( | L_BYTEA * | ba, |
const char * | str | ||
) |
[in] | ba | |
[in] | str | null-terminated string to be appended |
Definition at line 401 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 218 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 336 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 97 of file bytearray.c.
Referenced by 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 250 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 |
Notes: (1) If necessary, reallocs the byte array to size. (2) The max buffer size is 1 GB.
Definition at line 442 of file bytearray.c.
References L_Bytea::nalloc.
Referenced by l_byteaAppendData(), and l_byteaAppendString().
l_ok l_byteaFindEachSequence | ( | L_BYTEA * | ba, |
const l_uint8 * | sequence, | ||
size_t | seqlen, | ||
L_DNA ** | pda | ||
) |
[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 558 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 307 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 284 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 154 of file bytearray.c.
References fopenReadStream(), and l_byteaInitFromStream().
Referenced by saConcatenatePdfToData().
L_BYTEA* l_byteaInitFromMem | ( | const l_uint8 * | data, |
size_t | size | ||
) |
[in] | data | to be copied to the array |
[in] | size | amount of data |
Definition at line 125 of file bytearray.c.
Referenced by convertSegmentedFilesToPdf(), l_byteaCopy(), l_byteaSplit(), pixaConvertToPdfData(), saConvertFilesToPdfData(), and saConvertUnscaledFilesToPdfData().
L_BYTEA* l_byteaInitFromStream | ( | FILE * | fp | ) |
[in] | fp | file stream |
Definition at line 181 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; then ba2 is destroyed and its pointer is nulled. |
Notes: (1) It is a no-op, not an error, for ba2 to be null.
Definition at line 483 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 515 of file bytearray.c.
References l_byteaGetData(), l_byteaInitFromMem(), and L_Bytea::size.
l_ok l_byteaWrite | ( | const char * | fname, |
L_BYTEA * | ba, | ||
size_t | startloc, | ||
size_t | nbytes | ||
) |
[in] | fname | output file |
[in] | ba | |
[in] | startloc | first byte to output |
[in] | nbytes | number of bytes to write; use 0 to write to the end of the data array |
Definition at line 596 of file bytearray.c.
References fopenWriteStream(), and l_byteaWriteStream().
l_ok l_byteaWriteStream | ( | FILE * | fp, |
L_BYTEA * | ba, | ||
size_t | startloc, | ||
size_t | nbytes | ||
) |
[in] | fp | file stream opened for binary write |
[in] | ba | |
[in] | startloc | first byte to output |
[in] | nbytes | number of bytes to write; use 0 to write to the end of the data array |
Definition at line 630 of file bytearray.c.
References l_byteaGetData().
Referenced by l_byteaWrite().
|
static |
n'importe quoi
Definition at line 76 of file bytearray.c.