Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
worktree.c: zero new 'struct worktree' on allocation
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Tue, 22 Nov 2016 10:00:44 +0000
(17:00 +0700)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 23 Nov 2016 16:53:11 +0000
(08:53 -0800)
This keeps things a bit simpler when we add more fields, knowing that
default values are always zero.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
worktree.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
1e37181
)
diff --git
a/worktree.c
b/worktree.c
index f7869f8d6072c98c3e9be3387a9a3c19508e13ea..f7c1b5e24de237341f1228961bf35885c01f1583 100644
(file)
--- a/
worktree.c
+++ b/
worktree.c
@@
-91,16
+91,11
@@
static struct worktree *get_main_worktree(void)
if (parse_ref(path.buf, &head_ref, &is_detached) < 0)
goto done;
if (parse_ref(path.buf, &head_ref, &is_detached) < 0)
goto done;
- worktree = x
malloc(sizeof(struct
worktree));
+ worktree = x
calloc(1, sizeof(*
worktree));
worktree->path = strbuf_detach(&worktree_path, NULL);
worktree->path = strbuf_detach(&worktree_path, NULL);
- worktree->id = NULL;
worktree->is_bare = is_bare;
worktree->is_bare = is_bare;
- worktree->head_ref = NULL;
worktree->is_detached = is_detached;
worktree->is_detached = is_detached;
- worktree->is_current = 0;
add_head_info(&head_ref, worktree);
add_head_info(&head_ref, worktree);
- worktree->lock_reason = NULL;
- worktree->lock_reason_valid = 0;
done:
strbuf_release(&path);
done:
strbuf_release(&path);
@@
-138,16
+133,11
@@
static struct worktree *get_linked_worktree(const char *id)
if (parse_ref(path.buf, &head_ref, &is_detached) < 0)
goto done;
if (parse_ref(path.buf, &head_ref, &is_detached) < 0)
goto done;
- worktree = x
malloc(sizeof(struct
worktree));
+ worktree = x
calloc(1, sizeof(*
worktree));
worktree->path = strbuf_detach(&worktree_path, NULL);
worktree->id = xstrdup(id);
worktree->path = strbuf_detach(&worktree_path, NULL);
worktree->id = xstrdup(id);
- worktree->is_bare = 0;
- worktree->head_ref = NULL;
worktree->is_detached = is_detached;
worktree->is_detached = is_detached;
- worktree->is_current = 0;
add_head_info(&head_ref, worktree);
add_head_info(&head_ref, worktree);
- worktree->lock_reason = NULL;
- worktree->lock_reason_valid = 0;
done:
strbuf_release(&path);
done:
strbuf_release(&path);