mirror of
https://github.com/facebook/zstd.git
synced 2025-11-27 00:05:09 -05:00
fixed wrong size in pthread struct transfer
This commit is contained in:
parent
166901dc72
commit
62469c9f41
@ -196,19 +196,18 @@ static POOL_ctx* POOL_resize_internal(POOL_ctx* ctx, size_t numThreads)
|
|||||||
{ ZSTD_pthread_t* const threadPool = (ZSTD_pthread_t*)ZSTD_malloc(numThreads * sizeof(ZSTD_pthread_t), ctx->customMem);
|
{ ZSTD_pthread_t* const threadPool = (ZSTD_pthread_t*)ZSTD_malloc(numThreads * sizeof(ZSTD_pthread_t), ctx->customMem);
|
||||||
if (!threadPool) return NULL;
|
if (!threadPool) return NULL;
|
||||||
/* replace existing thread pool */
|
/* replace existing thread pool */
|
||||||
memcpy(threadPool, ctx->threads, ctx->threadCapacity);
|
memcpy(threadPool, ctx->threads, ctx->threadCapacity * sizeof(ctx->threads[0]));
|
||||||
ZSTD_free(ctx->threads, ctx->customMem);
|
ZSTD_free(ctx->threads, ctx->customMem);
|
||||||
ctx->threads = threadPool;
|
ctx->threads = threadPool;
|
||||||
/* Initialize additional threads */
|
/* Initialize additional threads */
|
||||||
{ size_t threadId;
|
{ size_t threadId;
|
||||||
for (threadId = ctx->threadCapacity; threadId < numThreads; ++threadId) {
|
for (threadId = ctx->threadCapacity; threadId < numThreads; ++threadId) {
|
||||||
if (ZSTD_pthread_create(&threadPool[threadId], NULL, &POOL_thread, ctx)) {
|
if (ZSTD_pthread_create(&threadPool[threadId], NULL, &POOL_thread, ctx)) {
|
||||||
break;
|
ctx->threadCapacity = threadId;
|
||||||
|
ctx->threadLimit = threadId;
|
||||||
|
return NULL; /* will release the pool */
|
||||||
} }
|
} }
|
||||||
if (threadId != numThreads) { /* not all threads successfully init */
|
} }
|
||||||
ctx->threadCapacity = threadId;
|
|
||||||
return NULL; /* will release the pool */
|
|
||||||
} } }
|
|
||||||
/* successfully expanded */
|
/* successfully expanded */
|
||||||
ctx->threadCapacity = numThreads;
|
ctx->threadCapacity = numThreads;
|
||||||
ctx->threadLimit = numThreads;
|
ctx->threadLimit = numThreads;
|
||||||
|
|||||||
@ -1643,13 +1643,13 @@ static int fuzzerTests_newAPI(U32 seed, U32 nbTests, unsigned startTest, double
|
|||||||
DISPLAYLEVEL(5, "Creating new context \n");
|
DISPLAYLEVEL(5, "Creating new context \n");
|
||||||
ZSTD_freeCCtx(zc);
|
ZSTD_freeCCtx(zc);
|
||||||
zc = ZSTD_createCCtx();
|
zc = ZSTD_createCCtx();
|
||||||
CHECK(zc==NULL, "ZSTD_createCCtx allocation error");
|
CHECK(zc == NULL, "ZSTD_createCCtx allocation error");
|
||||||
resetAllowed=0;
|
resetAllowed = 0;
|
||||||
}
|
}
|
||||||
if ((FUZ_rand(&lseed) & 0xFF) == 132) {
|
if ((FUZ_rand(&lseed) & 0xFF) == 132) {
|
||||||
ZSTD_freeDStream(zd);
|
ZSTD_freeDStream(zd);
|
||||||
zd = ZSTD_createDStream();
|
zd = ZSTD_createDStream();
|
||||||
CHECK(zd==NULL, "ZSTD_createDStream allocation error");
|
CHECK(zd == NULL, "ZSTD_createDStream allocation error");
|
||||||
ZSTD_initDStream_usingDict(zd, NULL, 0); /* ensure at least one init */
|
ZSTD_initDStream_usingDict(zd, NULL, 0); /* ensure at least one init */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user