Commit f054996d authored by Duy Nguyen's avatar Duy Nguyen Committed by Junio C Hamano

worktree.c: zero new 'struct worktree' on allocation

This keeps things a bit simpler when we add more fields, knowing that
default values are always zero.
Signed-off-by: Duy Nguyen's avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: 's avatarJunio C Hamano <gitster@pobox.com>
parent 1e371813
......@@ -91,16 +91,11 @@ static struct worktree *get_main_worktree(void)
if (parse_ref(path.buf, &head_ref, &is_detached) < 0)
goto done;
worktree = xmalloc(sizeof(struct worktree));
worktree = xcalloc(1, sizeof(*worktree));
worktree->path = strbuf_detach(&worktree_path, NULL);
worktree->id = NULL;
worktree->is_bare = is_bare;
worktree->head_ref = NULL;
worktree->is_detached = is_detached;
worktree->is_current = 0;
add_head_info(&head_ref, worktree);
worktree->lock_reason = NULL;
worktree->lock_reason_valid = 0;
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;
worktree = xmalloc(sizeof(struct worktree));
worktree = xcalloc(1, sizeof(*worktree));
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_current = 0;
add_head_info(&head_ref, worktree);
worktree->lock_reason = NULL;
worktree->lock_reason_valid = 0;
done:
strbuf_release(&path);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment