12
12
/* ====== Dependencies ======= */
13
13
#include "zstd_deps.h" /* size_t */
14
14
#include "debug.h" /* assert */
15
- #include "zstd_internal.h" /* ZSTD_customMalloc , ZSTD_customFree */
15
+ #include "zstd_internal.h" /* ZSTD_customCalloc , ZSTD_customFree */
16
16
#include "pool.h"
17
17
18
18
/* ====== Compiler specifics ====== */
@@ -126,7 +126,7 @@ POOL_ctx* POOL_create_advanced(size_t numThreads, size_t queueSize,
126
126
* empty and full queues.
127
127
*/
128
128
ctx -> queueSize = queueSize + 1 ;
129
- ctx -> queue = (POOL_job * )ZSTD_customMalloc (ctx -> queueSize * sizeof (POOL_job ), customMem );
129
+ ctx -> queue = (POOL_job * )ZSTD_customCalloc (ctx -> queueSize * sizeof (POOL_job ), customMem );
130
130
ctx -> queueHead = 0 ;
131
131
ctx -> queueTail = 0 ;
132
132
ctx -> numThreadsBusy = 0 ;
@@ -140,7 +140,7 @@ POOL_ctx* POOL_create_advanced(size_t numThreads, size_t queueSize,
140
140
}
141
141
ctx -> shutdown = 0 ;
142
142
/* Allocate space for the thread handles */
143
- ctx -> threads = (ZSTD_pthread_t * )ZSTD_customMalloc (numThreads * sizeof (ZSTD_pthread_t ), customMem );
143
+ ctx -> threads = (ZSTD_pthread_t * )ZSTD_customCalloc (numThreads * sizeof (ZSTD_pthread_t ), customMem );
144
144
ctx -> threadCapacity = 0 ;
145
145
ctx -> customMem = customMem ;
146
146
/* Check for errors */
@@ -220,7 +220,7 @@ static int POOL_resize_internal(POOL_ctx* ctx, size_t numThreads)
220
220
return 0 ;
221
221
}
222
222
/* numThreads > threadCapacity */
223
- { ZSTD_pthread_t * const threadPool = (ZSTD_pthread_t * )ZSTD_customMalloc (numThreads * sizeof (ZSTD_pthread_t ), ctx -> customMem );
223
+ { ZSTD_pthread_t * const threadPool = (ZSTD_pthread_t * )ZSTD_customCalloc (numThreads * sizeof (ZSTD_pthread_t ), ctx -> customMem );
224
224
if (!threadPool ) return 1 ;
225
225
/* replace existing thread pool */
226
226
ZSTD_memcpy (threadPool , ctx -> threads , ctx -> threadCapacity * sizeof (* threadPool ));
0 commit comments