refator: replace malloc with calloc

master
Sean McBride 3 years ago
parent 2be838b11e
commit 15c6606353

@ -44,7 +44,7 @@
*/ \
static inline struct vec_##TYPE *vec_##TYPE##_alloc(size_t capacity) \
{ \
struct vec_##TYPE *vec = (struct vec_##TYPE *)malloc(sizeof(struct vec_##TYPE)); \
struct vec_##TYPE *vec = (struct vec_##TYPE *)calloc(1, sizeof(struct vec_##TYPE)); \
if (vec == NULL) return vec; \
\
int rc = vec_##TYPE##_init(vec, capacity); \

@ -38,8 +38,8 @@ wasm_table_init(struct sledge_abi__wasm_table *wasm_table, size_t capacity)
static INLINE struct sledge_abi__wasm_table *
wasm_table_alloc(size_t capacity)
{
struct sledge_abi__wasm_table *wasm_table = (struct sledge_abi__wasm_table *)malloc(
sizeof(struct sledge_abi__wasm_table));
struct sledge_abi__wasm_table *wasm_table = (struct sledge_abi__wasm_table *)
calloc(1, sizeof(struct sledge_abi__wasm_table));
if (wasm_table == NULL) return NULL;
int rc = wasm_table_init(wasm_table, capacity);

@ -52,7 +52,7 @@ void
global_request_scheduler_deque_initialize()
{
/* Allocate and Initialize the global deque */
global_request_scheduler_deque = (struct deque_sandbox *)malloc(sizeof(struct deque_sandbox));
global_request_scheduler_deque = (struct deque_sandbox *)calloc(1, sizeof(struct deque_sandbox));
assert(global_request_scheduler_deque);
/* Note: Below is a Macro */
deque_init_sandbox(global_request_scheduler_deque, GLOBAL_REQUEST_SCHEDULER_DEQUE_CAPACITY);

@ -31,7 +31,7 @@ wasi_context_init(wasi_options_t *options)
/* TODO: Add default types */
assert(options != NULL);
wasi_context_t *wasi_context = (wasi_context_t *)malloc(sizeof(wasi_context_t));
wasi_context_t *wasi_context = (wasi_context_t *)calloc(1, sizeof(wasi_context_t));
if (options->argc > 0) {
assert(options->argv != NULL);

Loading…
Cancel
Save