Replace xmalloc+memset(0) with xcalloc.
PATCH 1/1 Replace xmalloc+memset(0) with xcalloc.
From: Peter Eriksen <[email protected]>
Date: Mon Apr 3 19:30:46 2006 +0100
Subject: [PATCH] Replace xmalloc+memset(0) with xcalloc.
Signed-off-by Peter Eriksen <[email protected]>
---
Is something like this considered a cleaup?
Regards,
Peter
apply.c | 9 +++------ blob.c | 3 +-- commit.c | 3 +-- convert-objects.c | 3 +-- http-push.c | 6 ++---- object.c | 6 ++---- read-tree.c | 9 +++------ tag.c | 3 +-- tree.c | 7 ++----- update-index.c | 6 ++---- 10 files changed, 18 insertions(+), 37 deletions(-)
d5c82aa8a2b9d776bb30efac17d15a8a596b47f4
apply.c +3 -6
@@ -924,8 +924,7 @@ static int parse_single_patch(char *linestruct fragment *fragment;int len; - fragment =xmalloc (sizeof (*fragment)); -memset (fragment,0 ,sizeof (*fragment)); + fragment =xcalloc (1 ,sizeof (*fragment)); len =parse_fragment (line, size, patch, fragment);if (len <=0 )die ("corrupt patch at line %d" , linenr);
@@ -1651,8 +1650,7 @@ static void add_index_file(const char *pif (!write_index)return ; - ce =xmalloc (ce_size); -memset (ce,0 , ce_size); + ce =xcalloc (1 , ce_size);memcpy (ce->name, path, namelen); ce->ce_mode =create_ce_mode (mode); ce->ce_flags =htons (namelen);
@@ -1808,8 +1806,7 @@ static int apply_patch(int fd, const chastruct patch *patch;int nr; - patch =xmalloc (sizeof (*patch)); -memset (patch,0 ,sizeof (*patch)); + patch =xcalloc (1 ,sizeof (*patch)); nr =parse_chunk (buffer + offset, size, patch);if (nr <0 )break ;
blob.c +1 -2
@@ -8,8 +8,7 @@ struct blob *lookup_blob(const unsigned {struct object *obj =lookup_object (sha1);if (!obj) { -struct blob *ret =xmalloc (sizeof (struct blob )); -memset (ret,0 ,sizeof (struct blob )); +struct blob *ret =xcalloc (1 ,sizeof (struct blob ));created_object (sha1, &ret->object); ret->object.type = blob_type;return ret;
commit.c +1 -2
@@ -73,8 +73,7 @@ struct commit *lookup_commit(const unsig {struct object *obj =lookup_object (sha1);if (!obj) { -struct commit *ret =xmalloc (sizeof (struct commit )); -memset (ret,0 ,sizeof (struct commit )); +struct commit *ret =xcalloc (1 ,sizeof (struct commit ));created_object (sha1, &ret->object); ret->object.type = commit_type;return ret;
convert-objects.c +1 -2
@@ -18,8 +18,7 @@ static struct entry * convert_entry(unsistatic struct entry *insert_new (unsigned char *sha1,int pos) { -struct entry *new =xmalloc (sizeof (struct entry )); -memset (new,0 ,sizeof (*new)); +struct entry *new =xcalloc (1 ,sizeof (struct entry ));memcpy (new->old_sha1, sha1,20 );memmove (convert + pos +1 , convert + pos, (nr_convert - pos) *sizeof (struct entry *)); convert[pos] = new;
http-push.c +2 -4
@@ -1008,8 +1008,7 @@ static int fetch_indices(void)struct active_request_slot *slot;struct slot_results results; - data =xmalloc (4096 ); -memset (data,0 ,4096 ); + data =xcalloc (1 ,4096 ); buffer.size =4096 ; buffer.posn =0 ; buffer.buffer = data;
@@ -2042,8 +2041,7 @@ static void update_remote_info_refs(struchar *if_header;struct curl_slist *dav_headers =NULL ; - buffer.buffer =xmalloc (4096 ); -memset (buffer.buffer,0 ,4096 ); + buffer.buffer =xcalloc (1 ,4096 ); buffer.size =4096 ; buffer.posn =0 ; remote_ls("refs/", (PROCESS_FILES | RECURSIVE),
object.c +2 -4
@@ -85,8 +85,7 @@ struct object_refs *alloc_object_refs(unstruct object_refs *refs;size_t size =sizeof (*refs) + count*sizeof (struct object *); - refs =xmalloc (size); -memset (refs,0 , size); + refs =xcalloc (1 , size); refs->count = count;return refs; }
@@ -178,8 +177,7 @@ struct object *lookup_unknown_object(con {struct object *obj =lookup_object (sha1);if (!obj) { -union any_object *ret =xmalloc (sizeof (*ret)); -memset (ret,0 ,sizeof (*ret)); +union any_object *ret =xcalloc (1 ,sizeof (*ret));created_object (sha1, &ret->object); ret->object.type =NULL ;return &ret->object;
read-tree.c +3 -6
@@ -133,11 +133,9 @@ #endif pathlen =strlen (first); ce_size =cache_entry_size (baselen + pathlen); - src =xmalloc (sizeof (struct cache_entry *) * src_size); -memset (src,0 ,sizeof (struct cache_entry *) * src_size); + src =xcalloc (src_size,sizeof (struct cache_entry *)); - subposns =xmalloc (sizeof (struct tree_list_entry *) * len); -memset (subposns,0 ,sizeof (struct tree_list_entry *) * len); + subposns =xcalloc (len,sizeof (struct tree_list_entry *));if (cache_name && !strcmp (cache_name, first)) { any_files =1 ;
@@ -177,8 +175,7 @@ #endifelse ce_stage =2 ; - ce =xmalloc (ce_size); -memset (ce,0 , ce_size); + ce =xcalloc (1 , ce_size); ce->ce_mode =create_ce_mode (posns[i]->mode); ce->ce_flags =create_ce_flags (baselen + pathlen, ce_stage);
tag.c +1 -2
@@ -19,8 +19,7 @@ struct tag *lookup_tag(const unsigned ch {struct object *obj =lookup_object (sha1);if (!obj) { -struct tag *ret =xmalloc (sizeof (struct tag )); -memset (ret,0 ,sizeof (struct tag )); +struct tag *ret =xcalloc (1 ,sizeof (struct tag ));created_object (sha1, &ret->object); ret->object.type = tag_type;return ret;
tree.c +2 -5
@@ -18,10 +18,8 @@ static int read_one_entry(unsigned char len =strlen (pathname); size =cache_entry_size (baselen + len); - ce =xmalloc (size); + ce =xcalloc (1 , size); -memset (ce,0 , size); - ce->ce_mode =create_ce_mode (mode); ce->ce_flags =create_ce_flags (baselen + len, stage);memcpy (ce->name, base, baselen);
@@ -130,8 +128,7 @@ struct tree *lookup_tree(const unsigned {struct object *obj =lookup_object (sha1);if (!obj) { -struct tree *ret =xmalloc (sizeof (struct tree )); -memset (ret,0 ,sizeof (struct tree )); +struct tree *ret =xcalloc (1 ,sizeof (struct tree ));created_object (sha1, &ret->object); ret->object.type = tree_type;return ret;
update-index.c +2 -4
@@ -114,8 +114,7 @@ static int add_file_to_cache(const char namelen =strlen (path); size =cache_entry_size (namelen); - ce =xmalloc (size); -memset (ce,0 , size); + ce =xcalloc (1 , size);memcpy (ce->name, path, namelen); ce->ce_flags =htons (namelen);fill_stat_cache_info (ce, &st);
@@ -312,8 +311,7 @@ static int add_cacheinfo(unsigned int mo len =strlen (path); size =cache_entry_size (len); - ce =xmalloc (size); -memset (ce,0 , size); + ce =xcalloc (1 , size);memcpy (ce->sha1, sha1,20 );memcpy (ce->name, path, len);
Signature · 1 line
1.3.0.rc1.g40e9