@@ -925,8 +925,7 @@ static int parse_single_patch(char *line, unsigned long size, struct patch *patc
925925 struct fragment * fragment ;
926926 int len ;
927927
928- fragment = xmalloc (sizeof (* fragment ));
929- memset (fragment , 0 , sizeof (* fragment ));
928+ fragment = xcalloc (1 , sizeof (* fragment ));
930929 len = parse_fragment (line , size , patch , fragment );
931930 if (len <= 0 )
932931 die ("corrupt patch at line %d" , linenr );
@@ -1652,8 +1651,7 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned
16521651 if (!write_index )
16531652 return ;
16541653
1655- ce = xmalloc (ce_size );
1656- memset (ce , 0 , ce_size );
1654+ ce = xcalloc (1 , ce_size );
16571655 memcpy (ce -> name , path , namelen );
16581656 ce -> ce_mode = create_ce_mode (mode );
16591657 ce -> ce_flags = htons (namelen );
@@ -1809,8 +1807,7 @@ static int apply_patch(int fd, const char *filename)
18091807 struct patch * patch ;
18101808 int nr ;
18111809
1812- patch = xmalloc (sizeof (* patch ));
1813- memset (patch , 0 , sizeof (* patch ));
1810+ patch = xcalloc (1 , sizeof (* patch ));
18141811 nr = parse_chunk (buffer + offset , size , patch );
18151812 if (nr < 0 )
18161813 break ;
0 commit comments