Exemplo n.º 1
0
void pc_context_destroy(pc_context_t *ctx)
{
    struct pc_block_s *scan = ctx->std_blocks;

    /* ### do something about unhandled errors?  */

    if (ctx->track_pool != NULL)
        pc_pool_destroy(ctx->track_pool);
    if (ctx->error_pool != NULL)
        pc_pool_destroy(ctx->error_pool);

    for (scan = ctx->std_blocks; scan != NULL; )
    {
        struct pc_block_s *next = scan->next;

        free(scan);
        scan = next;
    }

    while (ctx->nonstd_blocks != NULL)
    {
        /* Keep fetching the smallest node possible until it runs out.  */
        scan = pc__memtree_fetch(&ctx->nonstd_blocks,
                                 sizeof(struct pc_memtree_s));
        free(scan);
    }

    free(ctx);
}
Exemplo n.º 2
0
void pc__channel_cleanup(pc_context_t *ctx)
{
    ev_timer_stop(ctx->cctx->loop, &ctx->cctx->timeout);
    pc_pool_destroy(ctx->cctx->pool);
    ctx->cctx = NULL;
}