Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Critique for my code

Name: Anonymous 2012-12-21 10:06

Give your critique for this snippet, please.

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!

Name: Anonymous 2012-12-21 10:39

>>5
Fine. I'll make it kewler. Kewler names, kewl-dood hard tabs, and a kewler layout.


int prog (Directory *dir)
{
    Compile c = { dir, null, null, null, null };
    int error = 0;

    if (!(c.file_depender = tree_new())
     || !(c.topologics = list_doubly_create())
     || !(c.dependers = list_singly_create())
     || !(c.prog_files = list_singly_create())
     || list_singly_foreach(dir->files, (Function) depender_create, &c)
     || list_singly_foreach(c.dependers, (Function) depender_link, &c)
     || list_doubly_foreach(c.topologics, (Function) topologic_sort, &c)
     || (c.topologics->reverse = 1, list_doubly_foreach(c.topologics,
            (Function) topologic_compile, &c))) {
        error = 1;
        goto out;
    }
    if (!list_singly_count(c.prog_files))
        goto out;
    if (list_doubly_foreach(c.topologics, (Function) topologic_sort, &c))
        error = 1;
out:
    list_singly_foreach(c.dependers, (Function) depender_destroy, 0);
    list_singly_destroy(c.dependers);
    list_doubly_foreach(c.topologics, (Function) topologic_destroy, 0);
    list_doubly_destroy(c.topologics);
    list_singly_destroy(c.prog_files);
    tree_destroy(c.file_depender);
    return error;
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List