Skip to content

Commit

Permalink
Substitute xmalloc()+memset(0) with xcalloc().
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Eriksen <s022018@student.dtu.dk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Peter Eriksen authored and Junio C Hamano committed Jul 25, 2006
1 parent 143c89b commit 28f7581
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions builtin-add.c
Expand Up @@ -21,8 +21,7 @@ static void prune_directory(struct dir_struct *dir, const char **pathspec, int p

for (specs = 0; pathspec[specs]; specs++)
/* nothing */;
seen = xmalloc(specs);
memset(seen, 0, specs);
seen = xcalloc(specs, 1);

src = dst = dir->entries;
i = dir->nr;
Expand Down
3 changes: 1 addition & 2 deletions builtin-rm.c
Expand Up @@ -90,8 +90,7 @@ int cmd_rm(int argc, const char **argv, char **envp)
seen = NULL;
for (i = 0; pathspec[i] ; i++)
/* nothing */;
seen = xmalloc(i);
memset(seen, 0, i);
seen = xcalloc(i, 1);

for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
Expand Down
3 changes: 1 addition & 2 deletions combine-diff.c
Expand Up @@ -639,8 +639,7 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
/* deleted file */
result_size = 0;
elem->mode = 0;
result = xmalloc(1);
result[0] = 0;
result = xcalloc(1, 1);
}
if (0 <= fd)
close(fd);
Expand Down

0 comments on commit 28f7581

Please sign in to comment.