pub unsafe extern "C" fn ch_alloc_scratch(
    db: *const ch_database_t,
    scratch: *mut *mut ch_scratch_t
) -> ch_error_t
Expand description

Allocate a “scratch” space for use by Chimera.

This is required for runtime use, and one scratch space per thread, or concurrent caller, is required. Any allocator callback set by @ref ch_set_scratch_allocator() or @ref ch_set_allocator() will be used by this function.

@param db The database, as produced by @ref ch_compile().

@param scratch On first allocation, a pointer to NULL should be provided so a new scratch can be allocated. If a scratch block has been previously allocated, then a pointer to it should be passed back in to see if it is valid for this database block. If a new scratch block is required, the original will be freed and the new one returned, otherwise the previous scratch block will be returned. On success, the scratch block will be suitable for use with the provided database in addition to any databases that original scratch space was suitable for.

@return @ref CH_SUCCESS on successful allocation; @ref CH_NOMEM if the allocation fails. Other errors may be returned if invalid parameters are specified.