Skip to content

Commit

Permalink
calloc() to initialize memory
Browse files Browse the repository at this point in the history
  • Loading branch information
linquize committed May 16, 2013
1 parent 12f831f commit 7026ad8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/indexer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/transports/smart_protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/win32/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 7026ad8

Please sign in to comment.