Name: Anonymous 2012-12-21 10:06
Give your critique for this snippet, please.
How to improve aesthetics?
Thank you!
How to improve aesthetics?
int prog (Directory *directory)
{
int error = 0;
Compile compile = { directory, null, null, null, null };
if ((compile.file_depender = tree_new ()) == null)
goto exception;
if ((compile.topologics = list_doubly_create ()) == null)
goto exception;
if ((compile.dependers = list_singly_create ()) == null)
goto exception;
if ((compile.prog_files = list_singly_create ()) == null)
goto exception;
if (list_singly_foreach (directory->files, (Function)depender_create, &compile) != 0)
goto exception;
if (list_singly_foreach (compile.dependers, (Function)depender_link, &compile) != 0)
goto exception;
if (list_doubly_foreach (compile.topologics, (Function)topologic_sort, &compile) != 0)
goto exception;
compile.topologics->reverse = 1;
if (list_doubly_foreach (compile.topologics, (Function)topologic_compile, &compile) != 0)
goto exception;
if (list_singly_count (compile.prog_files) == 0)
goto exit;
if (compile_app_link (&compile) != 0)
goto exception;
goto exit;
exception:
error = 1;
exit:
list_singly_foreach (compile.dependers, (Function)depender_destroy, null);
list_singly_destroy (compile.dependers);
list_doubly_foreach (compile.topologics, (Function)topologic_destroy, null);
list_doubly_destroy (compile.topologics);
list_singly_destroy (compile.prog_files);
tree_destroy (compile.file_depender);
return error;
}Thank you!