[m-dev.] Tool for generating DU types in C

Julien Fischer juliensf at csse.unimelb.edu.au
Mon Mar 22 00:19:37 AEDT 2010


On Sun, 21 Mar 2010, Ralph Becket wrote:

>     a_b_tree
>     branch(a_b_tree l, a_b_tree r)
>     {
>         struct a_b_tree_branch *this =
>         (struct a_b_tree_branch *)
>             malloc(sizeof(struct a_b_tree_branch));
>         if (this == NULL) {
>             perror("a_b_tree:branch");
>             exit(1);
>         }
>         this->_tag = _a_b_tree_branch_tag;
>         this->l = l;
>         this->r = r;
>         if (l == NULL || r == NULL) {
>             fprintf(stderr, "a_b_tree: branch cannot have NULL arguments.\n");
>         }

Aren't you missing a call to exit() there?  Presumably you shouldn't
keep executing if a branch does have a NULL argument?

Julien.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the developers mailing list