diff options
author | Peter Eriksen <s022018@student.dtu.dk> | 2006-04-03 19:30:46 +0100 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-04-04 00:11:19 -0700 |
commit | 90321c106ca6e36c0e884ca677c9a52dea47bdde (patch) | |
tree | c574dde6987912d2197af80a5f7f8827cde263cc | |
parent | Use blob_, commit_, tag_, and tree_type throughout. (diff) | |
download | tgif-90321c106ca6e36c0e884ca677c9a52dea47bdde.tar.xz |
Replace xmalloc+memset(0) with xcalloc.
Signed-off-by: Peter Eriksen <s022018@student.dtu.dk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r-- | apply.c | 9 | ||||
-rw-r--r-- | blob.c | 3 | ||||
-rw-r--r-- | commit.c | 3 | ||||
-rw-r--r-- | convert-objects.c | 3 | ||||
-rw-r--r-- | http-push.c | 6 | ||||
-rw-r--r-- | object.c | 6 | ||||
-rw-r--r-- | read-tree.c | 9 | ||||
-rw-r--r-- | tag.c | 3 | ||||
-rw-r--r-- | tree.c | 7 | ||||
-rw-r--r-- | update-index.c | 6 |
10 files changed, 18 insertions, 37 deletions
@@ -925,8 +925,7 @@ static int parse_single_patch(char *line, unsigned long size, struct patch *patc struct 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); @@ -1652,8 +1651,7 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned if (!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); @@ -1809,8 +1807,7 @@ static int apply_patch(int fd, const char *filename) struct 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; @@ -8,8 +8,7 @@ struct blob *lookup_blob(const unsigned char *sha1) { 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; @@ -73,8 +73,7 @@ struct commit *lookup_commit(const unsigned char *sha1) { 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; diff --git a/convert-objects.c b/convert-objects.c index 57de37faa5..12aacef5a9 100644 --- a/convert-objects.c +++ b/convert-objects.c @@ -21,8 +21,7 @@ static struct entry * convert_entry(unsigned char *sha1); static 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; diff --git a/http-push.c b/http-push.c index ba7d9de234..b60fa8d241 100644 --- a/http-push.c +++ b/http-push.c @@ -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(struct remote_lock *lock) char *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), @@ -85,8 +85,7 @@ struct object_refs *alloc_object_refs(unsigned count) struct 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(const unsigned char *sha1) { 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; diff --git a/read-tree.c b/read-tree.c index eaff444196..58e56364e2 100644 --- a/read-tree.c +++ b/read-tree.c @@ -133,11 +133,9 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len, 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 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len, else 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); @@ -19,8 +19,7 @@ struct tag *lookup_tag(const unsigned char *sha1) { 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; @@ -18,9 +18,7 @@ static int read_one_entry(unsigned char *sha1, const char *base, int baselen, co len = strlen(pathname); size = cache_entry_size(baselen + len); - ce = xmalloc(size); - - memset(ce, 0, size); + ce = xcalloc(1, size); ce->ce_mode = create_ce_mode(mode); ce->ce_flags = create_ce_flags(baselen + len, stage); @@ -130,8 +128,7 @@ struct tree *lookup_tree(const unsigned char *sha1) { 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; diff --git a/update-index.c b/update-index.c index 797245ab27..1efac27c6b 100644 --- a/update-index.c +++ b/update-index.c @@ -114,8 +114,7 @@ static int add_file_to_cache(const char *path) 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 mode, const unsigned char *sha1, 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); |