static void task_queue_debug(task_queue *q)
{
	int	i;
	GET_GOUT;
	STRLIT("task_queue_debug ");
	for (i = 1; i <= q->curn; i++) {
		NDBG(i, d);
		PTREXP(q->x[i]);
		STREXP(q->x[i]->name);
		NDBG(q->x[i]->heap_pos, d);
		NDBG(q->x[i]->terminate, d);
		NDBG(q->x[i]->time, f);
	}
  PRINT_GOUT;
  FREE_GOUT;
}
/* Basic operations on tasks */
static task_env *activate(task_env *t)
{
	if (t) {
		MAY_DBG(FN;
		    STRLIT("activating task ");
		    PTREXP(t);
		    STREXP(t->name);
		    NDBG(t->heap_pos, d);
		    NDBG(t->time, f);
		    );
		assert(ash_nazg_gimbatul.type == type_hash("task_env"));
		if (t->heap_pos)
			task_queue_remove(&task_time_q, t->heap_pos);
		link_into(&t->l, &tasks);
		t->time = 0.0;
		t->heap_pos = 0;
		assert(ash_nazg_gimbatul.type == type_hash("task_env"));
	}
/* purecov: begin deadcode */
char *dbg_list(node_list const *nodes)
{
  u_int i;
  GET_NEW_GOUT;
  PTREXP(nodes);  NDBG(nodes->node_list_len, u); PTREXP(nodes->node_list_val);
  for(i = 0; i < nodes->node_list_len; i++){
    COPY_AND_FREE_GOUT(dbg_node_address(nodes->node_list_val[i]));
  }
  RET_GOUT;
}
Beispiel #4
0
const char *
ref_string (const char * str)
{
    block_t *b;

    b = BLOCK(str);
#ifdef DEBUG
    if (b != findblock(str)) {
        fatal("stralloc.c: called ref_string on non-shared string: %s.\n", str);
    }
#endif                          /* defined(DEBUG) */
    if (REFS(b))
        REFS(b)++;
    NDBG(b);
    ADD_STRING(SIZE(b));
    return str;
}
Beispiel #5
0
char *
     make_shared_string (const char * str)
{
    block_t *b;
    int h;

    b = hfindblock(str, h);     /* hfindblock macro sets h = StrHash(s) */
    if (!b) {
        b = alloc_new_string(str, h);
    } else {
        if (REFS(b))
            REFS(b)++;
        ADD_STRING(SIZE(b));
    }
    NDBG(b);
    return (STRING(b));
}
Beispiel #6
0
void
free_string (const char * str)
{
    block_t **prev, *b;
    int h;

    b = BLOCK(str);
    DEBUG_CHECK1(b != findblock(str),"stralloc.c: free_string called on non-shared string: %s.\n", str);
    
    /*
     * if a string has been ref'd USHRT_MAX times then we assume that its used
     * often enough to justify never freeing it.
     */
    if (!REFS(b))
        return;

    REFS(b)--;
    SUB_STRING(SIZE(b));

    NDBG(b);
    if (REFS(b) > 0)
        return;

    h = StrHash(str);
    prev = base_table + h;
    while ((b = *prev)) {
        if (STRING(b) == str) {
            *prev = NEXT(b);
            break;
        }
        prev = &(NEXT(b));
    }

    DEBUG_CHECK1(!b, "free_string: not found in string table! (\"%s\")\n", str);

    SUB_NEW_STRING(SIZE(b), sizeof(block_t));
    FREE(b);
    CHECK_STRING_STATS;
}