Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/common/pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ POOL_ctx* POOL_create_advanced(size_t numThreads, size_t queueSize,
/* Allocate the context and zero initialize */
ctx = (POOL_ctx*)ZSTD_customCalloc(sizeof(POOL_ctx), customMem);
if (!ctx) { return NULL; }
/* Record the allocator before anything can fail: POOL_free() needs it to release the
* allocations below with the same allocator that produced them. */
ctx->customMem = customMem;
/* Initialize the job queue.
* It needs one extra space since one space is wasted to differentiate
* empty and full queues.
Expand All @@ -143,7 +146,6 @@ POOL_ctx* POOL_create_advanced(size_t numThreads, size_t queueSize,
ctx->threads = (ZSTD_pthread_t*)ZSTD_customCalloc(numThreads * sizeof(ZSTD_pthread_t), customMem);
ctx->threadCapacity = 0;
ctx->threadLimit = numThreads;
ctx->customMem = customMem;
/* Check for errors */
if (!ctx->threads || !ctx->queue) { POOL_free(ctx); return NULL; }
/* Initialize the threads */
Expand Down