Browse Source

Substitute xmalloc()+memset(0) with xcalloc().

Signed-off-by: Peter Eriksen <s022018@student.dtu.dk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
maint
Peter Eriksen 19 years ago committed by Junio C Hamano
parent
commit
28f7581806
  1. 3
      builtin-add.c
  2. 3
      builtin-rm.c
  3. 3
      combine-diff.c

3
builtin-add.c

@ -21,8 +21,7 @@ static void prune_directory(struct dir_struct *dir, const char **pathspec, int p


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


src = dst = dir->entries; src = dst = dir->entries;
i = dir->nr; i = dir->nr;

3
builtin-rm.c

@ -90,8 +90,7 @@ int cmd_rm(int argc, const char **argv, char **envp)
seen = NULL; seen = NULL;
for (i = 0; pathspec[i] ; i++) for (i = 0; pathspec[i] ; i++)
/* nothing */; /* nothing */;
seen = xmalloc(i); seen = xcalloc(i, 1);
memset(seen, 0, i);


for (i = 0; i < active_nr; i++) { for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i]; struct cache_entry *ce = active_cache[i];

3
combine-diff.c

@ -639,8 +639,7 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
/* deleted file */ /* deleted file */
result_size = 0; result_size = 0;
elem->mode = 0; elem->mode = 0;
result = xmalloc(1); result = xcalloc(1, 1);
result[0] = 0;
} }
if (0 <= fd) if (0 <= fd)
close(fd); close(fd);

Loading…
Cancel
Save