calloc() to initialize memory
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
diff --git a/src/indexer.c b/src/indexer.c
index 91b7ba5..1b5339f 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -259,7 +259,7 @@ static int store_object(git_indexer_stream *idx)
entry = git__calloc(1, sizeof(*entry));
GITERR_CHECK_ALLOC(entry);
- pentry = git__malloc(sizeof(struct git_pack_entry));
+ pentry = git__calloc(1, sizeof(struct git_pack_entry));
GITERR_CHECK_ALLOC(pentry);
git_hash_final(&oid, ctx);
@@ -328,7 +328,7 @@ static int hash_and_save(git_indexer_stream *idx, git_rawobj *obj, git_off_t ent
return -1;
}
- pentry = git__malloc(sizeof(struct git_pack_entry));
+ pentry = git__calloc(1, sizeof(struct git_pack_entry));
GITERR_CHECK_ALLOC(pentry);
git_oid_cpy(&pentry->sha1, &oid);
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index 67d3095..6366167 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -576,7 +576,7 @@ static int add_push_report_pkt(git_push *push, git_pkt *pkt)
switch (pkt->type) {
case GIT_PKT_OK:
- status = git__malloc(sizeof(push_status));
+ status = git__calloc(1, sizeof(push_status));
GITERR_CHECK_ALLOC(status);
status->msg = NULL;
status->ref = git__strdup(((git_pkt_ok *)pkt)->ref);
diff --git a/src/win32/dir.c b/src/win32/dir.c
index 95ae506..8c51d83 100644
--- a/src/win32/dir.c
+++ b/src/win32/dir.c
@@ -32,7 +32,7 @@ git__DIR *git__opendir(const char *dir)
if (!dir || !init_filter(filter, sizeof(filter), dir))
return NULL;
- new = git__malloc(sizeof(*new));
+ new = git__calloc(1, sizeof(*new));
if (!new)
return NULL;