示例#1
0
//  --------------------------------------------------------------------------
//  Destructor
//
void
zfl_tree_destroy (zfl_tree_t **self_p)
{
    assert (self_p);
    if (*self_p) {
        zfl_tree_t *self = *self_p;

        //  Recurse like it's a normal binary tree
        if (self->child)
            zfl_tree_destroy (&self->child);
        if (self->next)
            zfl_tree_destroy (&self->next);

        zfl_blob_destroy (&self->blob);
        zfree (self->name);
        zfree (self);
        *self_p = NULL;
    }
}
示例#2
0
//  --------------------------------------------------------------------------
//  Destructor
//  Note, shuts down 0MQ
//
void
zfl_config_destroy (zfl_config_t **self_p)
{
    assert (self_p);
    if (*self_p) {
        zfl_config_t *self = *self_p;
        zfl_tree_destroy (&self->tree);
        zmq_term (self->context);
        free (self);
        *self_p = NULL;
    }
}
示例#3
0
//  --------------------------------------------------------------------------
//  Selftest
//
//  We create a tree of this structure:
//
//  root
//      type = zqueue
//      frontend
//          option
//              hwm = 1000
//              swap = 25000000     #  25MB
//              subscribe = #2
//          bind = tcp://eth0:5555
//      backend
//          bind = tcp://eth0:5556
//
int
zfl_tree_test (Bool verbose)
{
    zfl_tree_t
        *root,
        *type,
        *frontend,
        *option,
        *hwm,
        *swap,
        *subscribe,
        *bind,
        *backend;

    printf (" * zfl_tree: ");

    //  Left is first child, next is next sibling
    root     = zfl_tree_new ("root", NULL);
    type     = zfl_tree_new ("type", root);
    zfl_tree_set_string (type, "zqueue");
    frontend = zfl_tree_new ("frontend", root);
    option   = zfl_tree_new ("option", frontend);
    hwm      = zfl_tree_new ("hwm", option);
    zfl_tree_set_string (hwm, "1000");
    swap     = zfl_tree_new ("swap", option);
    zfl_tree_set_string (swap, "25000000");
    subscribe = zfl_tree_new ("subscribe", option);
    zfl_tree_set_printf (subscribe, "#%d", 2);
    bind     = zfl_tree_new ("bind", frontend);
    zfl_tree_set_string (bind, "tcp://eth0:5555");
    backend  = zfl_tree_new ("backend", root);
    bind     = zfl_tree_new ("bind", backend);
    zfl_tree_set_string (bind, "tcp://eth0:5556");
    if (verbose) {
        puts ("");
        zfl_tree_dump (root);
    }
    zfl_tree_destroy (&root);
    assert (root == NULL);
    printf ("OK\n");
    return 0;
}