summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8e44025)
raw | patch | inline | side by side (parent: 8e44025)
author | Peter Eriksen <s022018@student.dtu.dk> | |
Mon, 3 Apr 2006 18:30:46 +0000 (19:30 +0100) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Tue, 4 Apr 2006 07:11:19 +0000 (00:11 -0700) |
Signed-off-by: Peter Eriksen <s022018@student.dtu.dk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
apply.c | patch | blob | history | |
blob.c | patch | blob | history | |
commit.c | patch | blob | history | |
convert-objects.c | patch | blob | history | |
http-push.c | patch | blob | history | |
object.c | patch | blob | history | |
read-tree.c | patch | blob | history | |
tag.c | patch | blob | history | |
tree.c | patch | blob | history | |
update-index.c | patch | blob | history |
index cc3f12e5557d1b6c333c890d6d0209aee74742e5..33b4271288d3ee6ac786d7fc6009df1bf354055e 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -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);
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;
index 84ec1212e7010b8cbf535355d4114eded3007672..c1fdd861c3dedbbd670fcf07989501fd0f9b5fda 100644 (file)
--- a/blob.c
+++ b/blob.c
{
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;
diff --git a/commit.c b/commit.c
index eb42d517a4959d83593b7ba9e8fcbc650fea7a5e..d4976fb89f30eacaa1cfe015c6f7a035a1225f55 100644 (file)
--- a/commit.c
+++ b/commit.c
{
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 57de37faa53df5fb84247e2fd7486a108039676e..12aacef5a9c06adec2e7abb7c11051acc954225a 100644 (file)
--- a/convert-objects.c
+++ b/convert-objects.c
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 ba7d9de234277c912a19bd0f2036466c2ab7f521..b60fa8d2417c32cf72331e9869d4d3a3208e953f 100644 (file)
--- a/http-push.c
+++ b/http-push.c
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;
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),
diff --git a/object.c b/object.c
index b5c0ecf2b72bd520ee88b790aa424588178d02d3..4d46e0d5e4285251e60d2a6d938f38355ac5d2c0 100644 (file)
--- a/object.c
+++ b/object.c
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;
}
{
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 eaff4441963409ea058722ef08fcf181a34a0c96..58e56364e28af85b7ffd36a8c1d465d8c9d94d1f 100644 (file)
--- a/read-tree.c
+++ b/read-tree.c
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;
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);
index ac0e57398a2b236c9501ac43c517ead371b8988c..f390ee703036bc74d6447d7e96c828310a948c2b 100644 (file)
--- a/tag.c
+++ b/tag.c
{
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;
index 87e0d743f85605b8a77eda57f28ad1b25489905a..d599fb5e1a8b689460c1e53b319f88aeda9a4c89 100644 (file)
--- a/tree.c
+++ b/tree.c
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);
{
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 797245ab276543edc5d7605b57f5175278436234..1efac27c6baf26ed881099e91a3cbd5dbb3c2289 100644 (file)
--- a/update-index.c
+++ b/update-index.c
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);
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);