dir.[ch]: replace dir_init() with DIR_INIT
Remove the dir_init() function and replace it with a DIR_INIT macro. In many cases in the codebase we need to initialize things with a function for good reasons, e.g. needing to call another function on initialization. The "dir_init()" function was not one such case, and could trivially be replaced with a more idiomatic macro initialization pattern. The only place where we made use of its use of memset() was in dir_clear() itself, which resets the contents of an an existing struct pointer. Let's use the new "memcpy() a 'blank' struct on the stack" idiom to do that reset. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
5726a6b401
commit
ce93a4c612
@ -470,7 +470,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
int exit_status = 0;
|
||||
struct pathspec pathspec;
|
||||
struct dir_struct dir;
|
||||
struct dir_struct dir = DIR_INIT;
|
||||
int flags;
|
||||
int add_new_files;
|
||||
int require_pathspec;
|
||||
@ -577,7 +577,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
|
||||
die_in_unpopulated_submodule(&the_index, prefix);
|
||||
die_path_inside_submodule(&the_index, &pathspec);
|
||||
|
||||
dir_init(&dir);
|
||||
if (add_new_files) {
|
||||
int baselen;
|
||||
|
||||
|
Reference in New Issue
Block a user