|
CX Framework
Cross-platform C utility framework
|
Data Structures | |
| struct | ScratchPerThreadInfo |
| Per-thread scratch buffer state. More... | |
Typedefs | |
| typedef struct ScratchPerThreadInfo | ScratchPerThreadInfo |
| Per-thread scratch buffer state. | |
Functions | |
| void * | scratchGet (size_t sz) |
Scratch buffers provide thread-local temporary storage through a rotating buffer pool. Each thread maintains its own set of buffers that are automatically allocated on demand and reused across function calls within the same thread.
Critical Usage Rules:
Buffer Pool Behavior:
Example:
| void * scratchGet | ( | size_t | sz | ) |
Allocates a temporary scratch buffer from the thread-local rotating pool.
Returns the next buffer in the rotation, resizing if necessary. The buffer is NOT zero-filled and may contain stale data from previous uses. Buffers rotate after SCRATCH_NBUFFERS allocations, so earlier buffers may be overwritten.
Warning: Do not assume the returned pointer remains valid after calling other functions that may use scratch buffers, or after SCRATCH_NBUFFERS additional scratchGet calls.
| sz | Required buffer size in bytes (minimum SCRATCH_MIN_BUFFER_SIZE) |