|
LibTIFF 4.7.2
TIFF library public API and implementation reference
|
Apply handle allocation policies and manage owned array replacements. More...
Macros | |
| #define | LEADING_AREA_TO_STORE_ALLOC_SIZE (2 * SIZEOF_SIZE_T) |
| Reserve two size_t widths before a cumulatively tracked payload. | |
Functions | |
| static void | setByteArray (TIFF *tif, void **vpp, const void *vp, size_t nmemb, size_t elem_size) |
| Discard an old allocation and copy a replacement byte product. | |
| static void | _TIFFsetNString (TIFF *tif, char **cpp, const char *cp, uint32_t n) |
| Replace an owned string byte sequence with a copy. | |
| static void | _TIFFsetLong8Array (TIFF *tif, uint64_t **lpp, const uint64_t *lp, uint32_t n) |
| Replace an owned 64-bit integer array with a copy. | |
| static void | setDoubleArrayOneValue (TIFF *tif, double **vpp, double value, size_t nmemb) |
| Replace an owned double array with one repeated value. | |
| static int | setShortArrayWithCount (TIFF *tif, uint16_t **wpp, uint32_t *countp, const uint16_t *wp, uint32_t n) |
| Install a short array together with the number of elements it holds. | |
| static void | _TIFFEmitErrorAboveMaxSingleMemAlloc (TIFF *tif, const char *pszFunction, tmsize_t s) |
| Report a rejected single allocation-policy check. | |
| static void | _TIFFEmitErrorAboveMaxCumulatedMemAlloc (TIFF *tif, const char *pszFunction, tmsize_t s) |
| Report a rejected cumulative allocation-policy check. | |
| void | _TIFFsetByteArray (void **vpp, const void *vp, uint32_t n) |
| Replace an owned byte array with a copied array. | |
| void | _TIFFsetByteArrayExt (TIFF *tif, void **vpp, const void *vp, uint32_t n) |
| Replace an owned byte array with a copied array. | |
| void | _TIFFsetShortArray (uint16_t **wpp, const uint16_t *wp, uint32_t n) |
| Replace an owned short array with a copied array. | |
| void | _TIFFsetShortArrayExt (TIFF *tif, uint16_t **wpp, const uint16_t *wp, uint32_t n) |
| Replace an owned short array with a copied array. | |
| void | _TIFFsetLongArray (uint32_t **lpp, const uint32_t *lp, uint32_t n) |
| Replace an owned long array with a copied array. | |
| void | _TIFFsetLongArrayExt (TIFF *tif, uint32_t **lpp, const uint32_t *lp, uint32_t n) |
| Replace an owned long array with a copied array. | |
| void | _TIFFsetFloatArray (float **fpp, const float *fp, uint32_t n) |
| Replace an owned float array with a copied array. | |
| void | _TIFFsetFloatArrayExt (TIFF *tif, float **fpp, const float *fp, uint32_t n) |
| Replace an owned float array with a copied array. | |
| void | _TIFFsetDoubleArray (double **dpp, const double *dp, uint32_t n) |
| Replace an owned double array with a copied array. | |
| void | _TIFFsetDoubleArrayExt (TIFF *tif, double **dpp, const double *dp, uint32_t n) |
| Replace an owned double array with a copied array. | |
| void | _TIFFfreeExt (TIFF *tif, void *p) |
| Release a handle-aware allocation and its payload charge. | |
| void * | _TIFFmallocExt (TIFF *tif, tmsize_t s) |
| Allocate uninitialised bytes under a handle's allocation policy. | |
| void * | _TIFFcallocExt (TIFF *tif, tmsize_t nmemb, tmsize_t siz) |
| Allocate a zero-filled array under a handle's allocation policy. | |
| void * | _TIFFreallocExt (TIFF *tif, void *p, tmsize_t s) |
| Resize a handle-aware block or release it for a nonpositive size. | |
| void * | _TIFFCheckMalloc (TIFF *tif, tmsize_t nmemb, tmsize_t elem_size, const char *what) |
| Allocate a checked array with an allocation-failure diagnostic. | |
| void * | _TIFFCheckRealloc (TIFF *tif, void *buffer, tmsize_t nmemb, tmsize_t elem_size, const char *what) |
| Resize a checked array with an allocation-failure diagnostic. | |
Apply handle allocation policies and manage owned array replacements.
| #define LEADING_AREA_TO_STORE_ALLOC_SIZE (2 * SIZEOF_SIZE_T) |
Reserve two size_t widths before a cumulatively tracked payload.
Private accounting/alignment prefix; callers must not access or infer it.
Definition at line 193 of file tif_open.c.
Allocate a zero-filled array under a handle's allocation policy.
Use the same handle and accounting configuration for allocation, reallocation, and release. A cumulatively tracked block contains a private prefix and cannot be passed to _TIFFfree() or another handle's allocator. Release all such blocks before releasing their handle. NULL tif selects untracked allocation and is valid only with matching untracked blocks.
Checks signed-size product representability before allocating. Limit failures emit diagnostics; invalid/overflowing products and ordinary allocator failure have no direct diagnostic. Successful cumulative accounting charges only payload bytes. Does not retain inputs or perform file I/O.
| [in,out] | tif | Live accounting handle, or NULL for untracked allocation. |
| [in] | nmemb | Requested element count. |
| [in] | siz | Element size in bytes. |
Definition at line 224 of file tif_open.c.
References _TIFFcalloc(), _TIFFEmitErrorAboveMaxCumulatedMemAlloc(), _TIFFEmitErrorAboveMaxSingleMemAlloc(), LEADING_AREA_TO_STORE_ALLOC_SIZE, tiff::tif_cur_cumulated_mem_alloc, tiff::tif_max_cumulated_mem_alloc, tiff::tif_max_single_mem_alloc, and TIFF_TMSIZE_T_MAX.
Referenced by _TIFFReadEncodedStripAndAllocBuffer(), OJPEGWriteHeaderInfo(), TIFFHashSetNew(), TIFFHashSetRehash(), TIFFInitLERC(), TIFFInitZIP(), TIFFReadBufferSetup(), and TIFFReadDirectory().
|
extern |
Allocate a checked array with an allocation-failure diagnostic.
Checks the product through _TIFFMultiplySSize() with its optional arithmetic diagnostic disabled, then delegates to _TIFFreallocExt(). Zero/negative operands and overflowing products are rejected without calling realloc. Any NULL result emits an allocation diagnostic using tif->tif_name and what; limit rejection can therefore produce both a limit and an allocation diagnostic.
Equivalent to _TIFFCheckRealloc() with buffer = NULL. The returned block is uninitialised and must be released with _TIFFfreeExt() and the same handle.
| [in,out] | tif | Non-NULL live TIFF handle for allocation policy and diagnostics. |
| [in] | nmemb | Positive element count. |
| [in] | elem_size | Positive element size in bytes. |
| [in] | what | Non-NULL borrowed allocation-purpose description for diagnostics. |
Definition at line 274 of file tif_aux.c.
References _TIFFCheckRealloc().
Referenced by _TIFFMergeFields(), _TIFFRewriteField(), _TIFFVSetField(), allocChoppedUpStripArrays(), EstimateStripByteCounts(), JPEGDecodeRaw(), TIFFFetchDirectory(), TIFFFetchStripThing(), TIFFMergeFieldInfo(), TIFFPrintDirectory(), TIFFReadDirEntryArrayWithLimit(), TIFFReadDirEntryFloatArray(), TIFFReadDirEntryIfd8Array(), TIFFReadDirEntryLong8ArrayWithLimit(), TIFFReadDirEntryLongArray(), TIFFReadDirEntryShortArray(), TIFFReadDirEntrySlong8Array(), TIFFReadDirEntrySlongArray(), TIFFReadDirEntrySshortArray(), TIFFSetClientInfo(), TIFFSetupStrips(), TIFFWriteDirectorySec(), TIFFWriteDirectoryTagCheckedRationalArray(), TIFFWriteDirectoryTagCheckedRationalDoubleArray(), TIFFWriteDirectoryTagCheckedSrationalArray(), TIFFWriteDirectoryTagCheckedSrationalDoubleArray(), TIFFWriteDirectoryTagColormap(), TIFFWriteDirectoryTagIfdIfd8Array(), TIFFWriteDirectoryTagLong8Array(), TIFFWriteDirectoryTagLongLong8Array(), TIFFWriteDirectoryTagSampleformatArray(), TIFFWriteDirectoryTagShortPerSample(), TIFFWriteDirectoryTagSlong8Array(), TIFFWriteDirectoryTagSubifd(), and TIFFWriteDirectoryTagTransferfunction().
|
extern |
Resize a checked array with an allocation-failure diagnostic.
Checks the product through _TIFFMultiplySSize() with its optional arithmetic diagnostic disabled, then delegates to _TIFFreallocExt(). Zero/negative operands and overflowing products are rejected without calling realloc. Any NULL result emits an allocation diagnostic using tif->tif_name and what; limit rejection can therefore produce both a limit and an allocation diagnostic.
On any NULL result the old positive-size allocation remains owned and valid, including a rejected zero request; unlike _TIFFreallocExt(s <= 0), a zero count does not free it. Success invalidates the old pointer and returns storage for _TIFFfreeExt() with the matching handle. Preserve the old pointer until success.
| [in,out] | tif | Non-NULL live TIFF handle for allocation policy and diagnostics. |
| [in] | buffer | Matching handle-aware allocation to resize, or NULL. |
| [in] | nmemb | Positive element count. |
| [in] | elem_size | Positive element size in bytes. |
| [in] | what | Non-NULL borrowed allocation-purpose description for diagnostics. |
Definition at line 249 of file tif_aux.c.
References _TIFFMultiplySSize(), _TIFFreallocExt(), tiff::tif_name, TIFF_SSIZE_FORMAT, and TIFFErrorExtR().
Referenced by _TIFFCheckMalloc(), _TIFFMergeFields(), PixarLogEncode(), and TIFFMergeFieldInfo().
|
static |
Report a rejected cumulative allocation-policy check.
Formats the stored limit and size values through TIFFErrorExtR(). Does not allocate, free, update accounting, or decide the caller's return status. Diagnostic callbacks may have their normal side effects.
| [in] | tif | Non-NULL handle whose current cumulated total and cumulated limit are reported. |
| [in] | pszFunction | Borrowed diagnostic module name. |
| [in] | s | Requested payload bytes, or additional payload growth for cumulative realloc reporting. |
Definition at line 166 of file tif_open.c.
References tiff::tif_cur_cumulated_mem_alloc, tiff::tif_max_cumulated_mem_alloc, and TIFFErrorExtR().
Referenced by _TIFFcallocExt(), _TIFFmallocExt(), and _TIFFreallocExt().
|
static |
Report a rejected single allocation-policy check.
Formats the stored limit and size values through TIFFErrorExtR(). Does not allocate, free, update accounting, or decide the caller's return status. Diagnostic callbacks may have their normal side effects.
| [in] | tif | Non-NULL handle whose tif_max_single_mem_alloc is reported. |
| [in] | pszFunction | Borrowed diagnostic module name. |
| [in] | s | Requested payload bytes that exceeded the single-allocation limit. |
Definition at line 141 of file tif_open.c.
References tiff::tif_max_single_mem_alloc, and TIFFErrorExtR().
Referenced by _TIFFcallocExt(), _TIFFmallocExt(), and _TIFFreallocExt().
|
extern |
Release a handle-aware allocation and its payload charge.
Use the same handle and accounting configuration for allocation, reallocation, and release. A cumulatively tracked block contains a private prefix and cannot be passed to _TIFFfree() or another handle's allocator. Release all such blocks before releasing their handle. NULL tif selects untracked allocation and is valid only with matching untracked blocks.
NULL p is accepted. For a tracked block, reads its private prefix, subtracts the recorded payload size, and frees the underlying allocation. Invalidates all pointers into the block. There is no status result or direct diagnostic; debug assertions check accounting consistency. A wrong family/handle is not detected safely.
| [in,out] | tif | Matching live accounting handle, or NULL for an untracked block. |
| [in] | p | Owned matching allocation, or NULL. |
Definition at line 301 of file tif_open.c.
References _TIFFfree(), LEADING_AREA_TO_STORE_ALLOC_SIZE, tiff::tif_cur_cumulated_mem_alloc, and tiff::tif_max_cumulated_mem_alloc.
Referenced by _TIFFCheckDirNumberAndOffset(), _TIFFCreateAnonField(), _TIFFFetchStrileValue(), _TIFFFillStrilesInternal(), _TIFFreallocExt(), _TIFFRewriteField(), _TIFFSetupFields(), _TIFFVSetField(), allocChoppedUpStripArrays(), cancelColorMap(), cancelTransferFunction(), EstimateStripByteCounts(), fpAcc(), fpDiff(), gtStripContig(), gtStripSeparate(), gtTileContig(), gtTileSeparate(), initCIELabConversion(), JPEGCleanup(), JPEGDecodeRaw(), JPEGEncode(), JPEGFixupTagsSubsampling(), LERCCleanup(), LERCPostEncode(), LERCPreDecode(), LogL16InitState(), LogLuvCleanup(), LogLuvClose(), LogLuvInitState(), LZMACleanup(), LZWCleanup(), OJPEGCleanup(), OJPEGReadHeaderInfoSecStreamDht(), OJPEGReadHeaderInfoSecStreamDqt(), OJPEGReadHeaderInfoSecTablesAcTable(), OJPEGReadHeaderInfoSecTablesDcTable(), OJPEGReadHeaderInfoSecTablesQTable(), PackBitsPostEncode(), PixarLogCleanup(), PixarLogClose(), PixarLogMakeTables(), PixarLogSetupDecode(), PredictorEncodeRow(), PredictorEncodeTile(), setByteArray(), setDoubleArrayOneValue(), SetupBuffers(), setupMap(), TIFF_zfree(), TIFFAppendToStrip(), TIFFCleanup(), TIFFClientOpenExt(), TIFFDefaultDirectory(), TIFFDefaultTransferFunction(), TIFFFetchDirectory(), TIFFFetchNormalTag(), TIFFFetchStripThing(), TIFFFillStrip(), TIFFFillTile(), TIFFFreeDirectory(), TIFFGetConfiguredCODECs(), TIFFHashSetClearInternal(), TIFFHashSetDestroy(), TIFFHashSetNew(), TIFFHashSetRehash(), TIFFHashSetReturnListElt(), TIFFjpeg_tables_dest(), TIFFListDestroy(), TIFFPrintDirectory(), TIFFReadAndRealloc(), TIFFReadBufferSetup(), TIFFReadCustomDirectory(), TIFFReadDirectory(), TIFFReadDirEntryArrayWithLimit(), TIFFReadDirEntryByteArray(), TIFFReadDirEntryDoubleArray(), TIFFReadDirEntryFloatArray(), TIFFReadDirEntryIfd8Array(), TIFFReadDirEntryLong8ArrayWithLimit(), TIFFReadDirEntryLongArray(), TIFFReadDirEntryPersampleShort(), TIFFReadDirEntrySbyteArray(), TIFFReadDirEntryShortArray(), TIFFReadDirEntrySlong8Array(), TIFFReadDirEntrySlongArray(), TIFFReadDirEntrySshortArray(), TIFFRGBAImageEnd(), TIFFSetClientInfo(), TIFFSetupStrips(), TIFFUnlinkDirectory(), TIFFUnRegisterCODEC(), TIFFUnsetField(), TIFFWriteBufferSetup(), TIFFWriteDirectorySec(), TIFFWriteDirectoryTagCheckedRationalArray(), TIFFWriteDirectoryTagCheckedRationalDoubleArray(), TIFFWriteDirectoryTagCheckedSrationalArray(), TIFFWriteDirectoryTagCheckedSrationalDoubleArray(), TIFFWriteDirectoryTagColormap(), TIFFWriteDirectoryTagIfdIfd8Array(), TIFFWriteDirectoryTagLong8Array(), TIFFWriteDirectoryTagLongLong8Array(), TIFFWriteDirectoryTagSampleformatArray(), TIFFWriteDirectoryTagShortPerSample(), TIFFWriteDirectoryTagSlong8Array(), TIFFWriteDirectoryTagSubifd(), TIFFWriteDirectoryTagTransferfunction(), TWebPCleanup(), TWebPDecode(), TWebPPreEncode(), TWebPSetupDecode(), ZIPCleanup(), and ZSTDCleanup().
Allocate uninitialised bytes under a handle's allocation policy.
Use the same handle and accounting configuration for allocation, reallocation, and release. A cumulatively tracked block contains a private prefix and cannot be passed to _TIFFfree() or another handle's allocator. Release all such blocks before releasing their handle. NULL tif selects untracked allocation and is valid only with matching untracked blocks.
Positive configured limits are checked before allocation. Cumulative accounting tracks payload bytes and updates only after successful allocation; the prefix itself is not charged. Limit failures emit a diagnostic. Nonpositive size and ordinary allocator exhaustion return NULL without a direct diagnostic. Does not perform file I/O.
| [in,out] | tif | Live accounting handle, or NULL for untracked allocation. |
| [in] | s | Requested payload byte count. |
Definition at line 195 of file tif_open.c.
References _TIFFEmitErrorAboveMaxCumulatedMemAlloc(), _TIFFEmitErrorAboveMaxSingleMemAlloc(), _TIFFmalloc(), LEADING_AREA_TO_STORE_ALLOC_SIZE, tiff::tif_cur_cumulated_mem_alloc, tiff::tif_max_cumulated_mem_alloc, tiff::tif_max_single_mem_alloc, and TIFF_TMSIZE_T_MAX.
Referenced by _TIFFCheckDirNumberAndOffset(), _TIFFCreateAnonField(), _TIFFReadEncodedTileAndAllocBuffer(), BuildMapBitdepth16To8(), BuildMapUaToAa(), fpAcc(), fpDiff(), initCIELabConversion(), initYCbCrConversion(), JPEGEncode(), JPEGFixupTagsSubsampling(), LERCPostEncode(), LERCPreDecode(), LogL16InitState(), LogLuvInitState(), LZWSetupDecode(), LZWSetupEncode(), makebwmap(), makecmap(), OJPEGPreDecodeSkipScanlines(), OJPEGReadHeaderInfoSecStreamDht(), OJPEGReadHeaderInfoSecStreamDqt(), OJPEGReadHeaderInfoSecTablesAcTable(), OJPEGReadHeaderInfoSecTablesDcTable(), OJPEGReadHeaderInfoSecTablesQTable(), OJPEGWriteHeaderInfo(), PackBitsPreEncode(), PixarLogMakeTables(), PixarLogSetupDecode(), PredictorEncodeRow(), PredictorEncodeTile(), setByteArray(), setDoubleArrayOneValue(), SetupBuffers(), setupMap(), TIFF_zalloc(), TIFFAppendToStrip(), TIFFClientOpenExt(), TIFFDefaultRefBlackWhite(), TIFFDefaultTransferFunction(), TIFFFetchNormalTag(), TIFFHashSetGetNewListElt(), TIFFHashSetNew(), TIFFInitJPEG(), TIFFInitLZMA(), TIFFInitLZW(), TIFFInitOJPEG(), TIFFInitPixarLog(), TIFFInitSGILog(), TIFFInitWebP(), TIFFInitZSTD(), TIFFjpeg_tables_dest(), TIFFReadCustomDirectory(), TIFFReadDirectory(), TIFFReadDirEntryByteArray(), TIFFReadDirEntryDoubleArray(), TIFFReadDirEntrySbyteArray(), TIFFRegisterCODEC(), TIFFRGBAImageBegin(), TIFFWriteBufferSetup(), TIFFWriteDirectorySec(), TWebPDecode(), and TWebPPreEncode().
Resize a handle-aware block or release it for a nonpositive size.
Use the same handle and accounting configuration for allocation, reallocation, and release. A cumulatively tracked block contains a private prefix and cannot be passed to _TIFFfree() or another handle's allocator. Release all such blocks before releasing their handle. NULL tif selects untracked allocation and is valid only with matching untracked blocks.
Preserves the initial min(old size, s) bytes on success; the old pointer becomes invalid even if the address is unchanged. Grown bytes are uninitialised. Check through a temporary result pointer. Successful cumulative accounting replaces the old payload charge with the new one. Limit failures emit diagnostics; ordinary exhaustion does not directly report an error. Does not perform file I/O.
| [in,out] | tif | Matching live accounting handle, or NULL for an untracked block. |
| [in] | p | Matching handle-aware allocation, or NULL. |
| [in] | s | New payload byte count; a nonpositive value releases p. |
Definition at line 257 of file tif_open.c.
References _TIFFEmitErrorAboveMaxCumulatedMemAlloc(), _TIFFEmitErrorAboveMaxSingleMemAlloc(), _TIFFfreeExt(), _TIFFrealloc(), LEADING_AREA_TO_STORE_ALLOC_SIZE, tiff::tif_cur_cumulated_mem_alloc, tiff::tif_max_cumulated_mem_alloc, tiff::tif_max_single_mem_alloc, and TIFF_TMSIZE_T_MAX.
Referenced by _TIFFCheckRealloc(), _TIFFFetchStrileValue(), _TIFFVSetField(), SetupBuffers(), tables_empty_output_buffer(), TIFFGetConfiguredCODECs(), TIFFGrowStrips(), TIFFReadAndRealloc(), and TIFFReadDirEntryDataAndRealloc().
|
extern |
Replace an owned byte array with a copied array.
Detaches the old destination, copies into a new allocation, and then frees the old one. A NULL source, zero/rejected byte product, or allocation failure leaves the destination NULL; the old data is still freed and lost. This is not a failure-preserving realloc operation. The source pointer is borrowed only during the copy; because the copy precedes the free, it may point into the old destination allocation.
Uses the untracked family through a NULL handle. Release the replacement with _TIFFfree(). Returns no status, and no diagnostic is emitted on any failure. No file I/O occurs.
| [in,out] | vpp | Non-NULL pointer to an owned compatible array or NULL array pointer; replaced or cleared. |
| [in] | vp | Readable source for n elements, or NULL to clear; may point into the old destination allocation. |
| [in] | n | Element count in bytes. |
Definition at line 103 of file tif_dir.c.
References setByteArray().
|
extern |
Replace an owned byte array with a copied array.
Detaches the old destination, copies into a new allocation, and then frees the old one. A NULL source, zero/rejected byte product, or allocation failure leaves the destination NULL; the old data is still freed and lost. This is not a failure-preserving realloc operation. The source pointer is borrowed only during the copy; because the copy precedes the free, it may point into the old destination allocation.
Uses handle-aware allocation/free and must preserve the same accounting context. Release the replacement with _TIFFfreeExt() using that context. Returns no status. Product rejection and ordinary allocation failure have no direct diagnostic; handle limit failures may report through the allocation helpers. No file I/O occurs.
| [in,out] | tif | Matching live accounting handle, or NULL for untracked storage. |
| [in,out] | vpp | Non-NULL pointer to an owned compatible array or NULL array pointer; replaced or cleared. |
| [in] | vp | Readable source for n elements, or NULL to clear; may point into the old destination allocation. |
| [in] | n | Element count in bytes. |
Definition at line 107 of file tif_dir.c.
References setByteArray().
Referenced by JPEGVSetField().
|
extern |
Replace an owned double array with a copied array.
Detaches the old destination, copies into a new allocation, and then frees the old one. A NULL source, zero/rejected byte product, or allocation failure leaves the destination NULL; the old data is still freed and lost. This is not a failure-preserving realloc operation. The source pointer is borrowed only during the copy; because the copy precedes the free, it may point into the old destination allocation.
Uses the untracked family through a NULL handle. Release the replacement with _TIFFfree(). Returns no status, and no diagnostic is emitted on any failure. No file I/O occurs.
| [in,out] | dpp | Non-NULL pointer to an owned compatible array or NULL array pointer; replaced or cleared. |
| [in] | dp | Readable source for n elements, or NULL to clear; may point into the old destination allocation. |
| [in] | n | Element count. |
Definition at line 180 of file tif_dir.c.
References setByteArray().
|
extern |
Replace an owned double array with a copied array.
Detaches the old destination, copies into a new allocation, and then frees the old one. A NULL source, zero/rejected byte product, or allocation failure leaves the destination NULL; the old data is still freed and lost. This is not a failure-preserving realloc operation. The source pointer is borrowed only during the copy; because the copy precedes the free, it may point into the old destination allocation.
Uses handle-aware allocation/free and must preserve the same accounting context. Release the replacement with _TIFFfreeExt() using that context. Returns no status. Product rejection and ordinary allocation failure have no direct diagnostic; handle limit failures may report through the allocation helpers. No file I/O occurs.
| [in,out] | tif | Matching live accounting handle, or NULL for untracked storage. |
| [in,out] | dpp | Non-NULL pointer to an owned compatible array or NULL array pointer; replaced or cleared. |
| [in] | dp | Readable source for n elements, or NULL to clear; may point into the old destination allocation. |
| [in] | n | Element count. |
Definition at line 184 of file tif_dir.c.
References setByteArray().
Referenced by _TIFFVSetField().
|
extern |
Replace an owned float array with a copied array.
Detaches the old destination, copies into a new allocation, and then frees the old one. A NULL source, zero/rejected byte product, or allocation failure leaves the destination NULL; the old data is still freed and lost. This is not a failure-preserving realloc operation. The source pointer is borrowed only during the copy; because the copy precedes the free, it may point into the old destination allocation.
Uses the untracked family through a NULL handle. Release the replacement with _TIFFfree(). Returns no status, and no diagnostic is emitted on any failure. No file I/O occurs.
| [in,out] | fpp | Non-NULL pointer to an owned compatible array or NULL array pointer; replaced or cleared. |
| [in] | fp | Readable source for n elements, or NULL to clear; may point into the old destination allocation. |
| [in] | n | Element count. |
Definition at line 171 of file tif_dir.c.
References setByteArray().
|
extern |
Replace an owned float array with a copied array.
Detaches the old destination, copies into a new allocation, and then frees the old one. A NULL source, zero/rejected byte product, or allocation failure leaves the destination NULL; the old data is still freed and lost. This is not a failure-preserving realloc operation. The source pointer is borrowed only during the copy; because the copy precedes the free, it may point into the old destination allocation.
Uses handle-aware allocation/free and must preserve the same accounting context. Release the replacement with _TIFFfreeExt() using that context. Returns no status. Product rejection and ordinary allocation failure have no direct diagnostic; handle limit failures may report through the allocation helpers. No file I/O occurs.
| [in,out] | tif | Matching live accounting handle, or NULL for untracked storage. |
| [in,out] | fpp | Non-NULL pointer to an owned compatible array or NULL array pointer; replaced or cleared. |
| [in] | fp | Readable source for n elements, or NULL to clear; may point into the old destination allocation. |
| [in] | n | Element count. |
Definition at line 175 of file tif_dir.c.
References setByteArray().
Referenced by _TIFFVSetField().
|
static |
Replace an owned 64-bit integer array with a copy.
Delegates to setByteArray() with its destructive replacement, checked- product, ownership, and diagnostic rules. Allocation failure loses the old allocation and leaves a NULL result slot. Returns no status.
| [in,out] | tif | Matching live accounting handle, or NULL. |
| [in,out] | lpp | Non-NULL owned-allocation slot; cleared before copying. |
| [in] | lp | Readable source, or NULL to clear; may point into the old allocation. |
| [in] | n | Number of uint64_t elements. |
Definition at line 165 of file tif_dir.c.
References setByteArray().
Referenced by _TIFFVSetField().
|
extern |
Replace an owned long array with a copied array.
Detaches the old destination, copies into a new allocation, and then frees the old one. A NULL source, zero/rejected byte product, or allocation failure leaves the destination NULL; the old data is still freed and lost. This is not a failure-preserving realloc operation. The source pointer is borrowed only during the copy; because the copy precedes the free, it may point into the old destination allocation.
Uses the untracked family through a NULL handle. Release the replacement with _TIFFfree(). Returns no status, and no diagnostic is emitted on any failure. No file I/O occurs.
| [in,out] | lpp | Non-NULL pointer to an owned compatible array or NULL array pointer; replaced or cleared. |
| [in] | lp | Readable source for n elements, or NULL to clear; may point into the old destination allocation. |
| [in] | n | Element count. |
Definition at line 141 of file tif_dir.c.
References setByteArray().
|
extern |
Replace an owned long array with a copied array.
Detaches the old destination, copies into a new allocation, and then frees the old one. A NULL source, zero/rejected byte product, or allocation failure leaves the destination NULL; the old data is still freed and lost. This is not a failure-preserving realloc operation. The source pointer is borrowed only during the copy; because the copy precedes the free, it may point into the old destination allocation.
Uses handle-aware allocation/free and must preserve the same accounting context. Release the replacement with _TIFFfreeExt() using that context. Returns no status. Product rejection and ordinary allocation failure have no direct diagnostic; handle limit failures may report through the allocation helpers. No file I/O occurs.
| [in,out] | tif | Matching live accounting handle, or NULL for untracked storage. |
| [in,out] | lpp | Non-NULL pointer to an owned compatible array or NULL array pointer; replaced or cleared. |
| [in] | lp | Readable source for n elements, or NULL to clear; may point into the old destination allocation. |
| [in] | n | Element count. |
Definition at line 145 of file tif_dir.c.
References setByteArray().
|
static |
Replace an owned string byte sequence with a copy.
Delegates to setByteArray() with its destructive replacement, checked- product, ownership, and diagnostic rules. Allocation failure loses the old allocation and leaves a NULL result slot. Returns no status.
| [in,out] | tif | Matching live accounting handle, or NULL. |
| [in,out] | cpp | Non-NULL owned-allocation slot; cleared before copying. |
| [in] | cp | Readable source, or NULL to clear; may point into the old allocation. |
| [in] | n | Number of bytes; no terminator is added. |
Definition at line 126 of file tif_dir.c.
References setByteArray().
Referenced by _TIFFVSetField().
|
extern |
Replace an owned short array with a copied array.
Detaches the old destination, copies into a new allocation, and then frees the old one. A NULL source, zero/rejected byte product, or allocation failure leaves the destination NULL; the old data is still freed and lost. This is not a failure-preserving realloc operation. The source pointer is borrowed only during the copy; because the copy precedes the free, it may point into the old destination allocation.
Uses the untracked family through a NULL handle. Release the replacement with _TIFFfree(). Returns no status, and no diagnostic is emitted on any failure. No file I/O occurs.
| [in,out] | wpp | Non-NULL pointer to an owned compatible array or NULL array pointer; replaced or cleared. |
| [in] | wp | Readable source for n elements, or NULL to clear; may point into the old destination allocation. |
| [in] | n | Element count. |
Definition at line 131 of file tif_dir.c.
References setByteArray().
|
extern |
Replace an owned short array with a copied array.
Detaches the old destination, copies into a new allocation, and then frees the old one. A NULL source, zero/rejected byte product, or allocation failure leaves the destination NULL; the old data is still freed and lost. This is not a failure-preserving realloc operation. The source pointer is borrowed only during the copy; because the copy precedes the free, it may point into the old destination allocation.
Uses handle-aware allocation/free and must preserve the same accounting context. Release the replacement with _TIFFfreeExt() using that context. Returns no status. Product rejection and ordinary allocation failure have no direct diagnostic; handle limit failures may report through the allocation helpers. No file I/O occurs.
| [in,out] | tif | Matching live accounting handle, or NULL for untracked storage. |
| [in,out] | wpp | Non-NULL pointer to an owned compatible array or NULL array pointer; replaced or cleared. |
| [in] | wp | Readable source for n elements, or NULL to clear; may point into the old destination allocation. |
| [in] | n | Element count. |
Definition at line 135 of file tif_dir.c.
References setByteArray().
Referenced by _TIFFVSetField(), setExtraSamples(), setShortArrayWithCount(), and TIFFReadDirectory().
|
static |
Discard an old allocation and copy a replacement byte product.
Detaches and clears *vpp before checking/copying, and frees the old allocation only after the copy, so the source may alias it. With a non-NULL source, checks the product silently through _TIFFMultiplySSize(NULL, ..., NULL) and allocates only a positive valid result. Failure leaves *vpp NULL and does not preserve old contents. An allocator limit may report a diagnostic, but other size/allocation failures have no direct diagnostic. The replacement uses the matching _TIFFfreeExt() context.
| [in,out] | tif | Matching live accounting handle, or NULL. |
| [in,out] | vpp | Non-NULL owner slot for a compatible allocation, or a NULL allocation. |
| [in] | vp | Readable source, or NULL to clear; may point into the old allocation. |
| [in] | nmemb | Count representable by tmsize_t for the checked product. |
| [in] | elem_size | Element byte size representable by tmsize_t. |
Definition at line 86 of file tif_dir.c.
References _TIFFfreeExt(), _TIFFmallocExt(), _TIFFmemcpy(), and _TIFFMultiplySSize().
Referenced by _TIFFsetByteArray(), _TIFFsetByteArrayExt(), _TIFFsetDoubleArray(), _TIFFsetDoubleArrayExt(), _TIFFsetFloatArray(), _TIFFsetFloatArrayExt(), _TIFFsetLong8Array(), _TIFFsetLongArray(), _TIFFsetLongArrayExt(), _TIFFsetNString(), _TIFFsetShortArray(), _TIFFsetShortArrayExt(), and _TIFFVSetField().
|
static |
Replace an owned double array with one repeated value.
Frees the previous allocation before attempting the new one. The size multiplication is not overflow-checked here: callers must satisfy the representability precondition. Zero count or allocation failure leaves *vpp NULL and discards old data. Returns no status; only allocator policy diagnostics may be emitted. Release the replacement with the matching _TIFFfreeExt() context.
| [in,out] | tif | Matching live accounting handle, or NULL. |
| [in,out] | vpp | Non-NULL owner slot for a matching double array or NULL. |
| [in] | value | Value to assign to every new element. |
| [in] | nmemb | Element count; its conversion and byte product must fit tmsize_t. |
Definition at line 208 of file tif_dir.c.
References _TIFFfreeExt(), _TIFFmallocExt(), and _TIFFMultiplySSize().
Referenced by _TIFFVSetField().
|
static |
Install a short array together with the number of elements it holds.
The count is the only record the library keeps of the length of the array, so it is written here and nowhere else, and is cleared whenever the array is not installed.
| [in,out] | tif | Directory handle owning the allocation. |
| [in,out] | wpp | Owner slot for the array. |
| [out] | countp | Recorded length that belongs to wpp. |
| [in] | wp | Readable source of n entries. |
| [in] | n | Number of entries to copy. |
Definition at line 241 of file tif_dir.c.
References _TIFFsetShortArrayExt().
Referenced by setColorMap(), and setTransferFunction().