Example #1
0
File: sink.c Project: Chunjie/hilti
static void __unlink_state(binpac_sink* sink, __parser_state* state, hlt_execution_context* ctx)
{
    __parser_state* prev = 0;
    __parser_state* s = sink->head;

    while ( s ) {
        if ( s == state )
            break;

        prev = s;
        s = s->next;
    }

    assert(s);

    if ( prev )
        prev->next = state->next;

    else
        sink->head = state->next;

    GC_CLEAR(state->data, hlt_bytes, ctx);
    GC_CLEAR(state->resume, hlt_exception, ctx);
    GC_DTOR_GENERIC(&state->pobj, state->parser->type_info, ctx);
    state->pobj = 0;
    GC_CLEAR(state->parser, hlt_BinPACHilti_Parser, ctx);
    hlt_free(state);
}
Example #2
0
void hlt_execution_context_delete(hlt_execution_context* ctx)
{
    hlt_exception* excpt = 0;

    // Do this first, it may still need the context.
    hlt_timer_mgr_expire(ctx->tmgr, 0, &excpt, ctx);
    GC_DTOR(ctx->tmgr, hlt_timer_mgr, ctx);

    __hlt_globals_dtor(ctx);

    GC_DTOR(ctx->excpt, hlt_exception, ctx);

    if ( ctx->fiber )
        hlt_fiber_delete(ctx->fiber, ctx);

    if ( ctx->pstate )
        __hlt_profiler_state_delete(ctx->pstate);

    if ( ctx->tcontext ) {
        GC_DTOR_GENERIC(&ctx->tcontext, ctx->tcontext_type, ctx);
    }

    __hlt_fiber_pool_delete(ctx->fiber_pool);

    if ( ctx->nullbuffer )
        __hlt_memory_nullbuffer_delete(ctx->nullbuffer, ctx);

    hlt_free(ctx);
}
Example #3
0
void __hlt_context_set_thread_context(hlt_execution_context* ctx, hlt_type_info* type, void* tctx)
{
    GC_DTOR_GENERIC(&ctx->tcontext, ctx->tcontext_type, ctx);
    ctx->tcontext = tctx;
    ctx->tcontext_type = type;
    GC_CCTOR_GENERIC(&ctx->tcontext, ctx->tcontext_type, ctx);
}
Example #4
0
File: sink.c Project: Chunjie/hilti
static void __dtor_state(__parser_state* state, hlt_execution_context* ctx)
{
    for ( ; state; state = state->next ) {
        GC_DTOR(state->parser, hlt_BinPACHilti_Parser, ctx);
        GC_DTOR_GENERIC(&state->pobj, state->parser->type_info, ctx);
        GC_DTOR(state->data, hlt_bytes, ctx);
        GC_DTOR(state->resume, hlt_exception, ctx);
    }
}
Example #5
0
void hlt_exception_dtor(hlt_type_info* ti, hlt_exception* excpt, hlt_execution_context* ctx)
{
    if ( excpt->arg ) {
        GC_DTOR_GENERIC(excpt->arg, excpt->type->argtype, ctx);
        hlt_free(excpt->arg);
    }

    if ( excpt->fiber )
        hlt_fiber_delete(excpt->fiber, 0);
}
Example #6
0
void hlt_classifier_dtor(hlt_type_info* ti, hlt_classifier* c, hlt_execution_context* ctx)
{
    if ( ! c->rules )
        return;

    for ( int i = 0; i < c->num_rules; i++ ) {
        hlt_classifier_rule* r = c->rules[i];

        for ( int j = 0; j < c->num_fields; j++ )
            hlt_free(r->fields[j]);

        hlt_free(r->fields);
        GC_DTOR_GENERIC(r->value, c->value_type, ctx);
        hlt_free(r->value);
        hlt_free(r);
    }

    hlt_free(c->rules);
}