コード例 #1
0
ファイル: tclist.c プロジェクト: BackupTheBerlios/tcforge-svn
int tc_list_fini(TCList *L)
{
    /* if !use_cache, this will not hurt anyone */
    foreach_item(L->head,  DIR_FORWARD, free_item, NULL);
    foreach_item(L->cache, DIR_FORWARD, free_item, NULL);
    /* now reset to clean status */
    return tc_list_init(L, 0);
}
コード例 #2
0
ファイル: tclist.c プロジェクト: BackupTheBerlios/tcforge-svn
void tc_list_del(TCList *L, int deepclean)
{
    if (deepclean) {
        foreach_item(L->head,  DIR_FORWARD, free_item_all, NULL);
        /* if !use_cache, this will not hurt anyone */
        foreach_item(L->cache, DIR_FORWARD, free_item_all, NULL);
    }
    tc_free(L);
}
コード例 #3
0
ファイル: out_ascii.c プロジェクト: ebichu/dd-wrt
static void ascii_draw_node(node_t *n, void *arg)
{
	if (n->n_name) {
		if (get_nnodes() > 1)
			printf("%s:\n", n->n_name);
		foreach_item(n, ascii_draw_item, n);
	}
}
コード例 #4
0
ファイル: cgi_request.c プロジェクト: ncbi/sra-tools
rc_t add_cgi_request_params( struct cgi_request * request, const char * fmt, const VNamelist * src )
{
    rc_t rc;
    if ( request == NULL || fmt == NULL || src == NULL )
        rc = RC( rcVDB, rcNoTarg, rcConstructing, rcParam, rcNull );
    else
    {
        add_ctx actx = { request, fmt };
        rc = foreach_item( src, add_item, &actx );
    }
    return rc;
}
コード例 #5
0
ファイル: tclist.c プロジェクト: BackupTheBerlios/tcforge-svn
static TCListItem *find_position(TCList *L, int pos)
{
    TCListItem *ret = NULL;
    if (L) {
        /* common cases first */
        if (pos == 0) {
            ret = L->head;
        } else if (pos == -1) {
            ret = L->tail;
        } else {
            /* if we're here we can't avoid a full scan */
            struct find_data FD = { DIR_FORWARD, 0, 0, NULL };
            if (pos >= 0) {
                FD.dir      = DIR_FORWARD; /* enforce */
                FD.cur_idx  = 0;
                FD.stop_idx = pos;
            } else {
                /* 
                 * we're perfectly fine with negative indexes;
                 * we'll just starting from the end going backwards
                 * with -1 being the last element.
                 */
                FD.dir      = DIR_BACKWARD;
                FD.cur_idx  = L->nelems - 1;
                FD.stop_idx = L->nelems + pos;
            }
            /* we can now catch some over/under-run common cases */
            if (FD.stop_idx > 0 || FD.stop_idx < L->nelems) {
                /* we want something in the middle, so let's run */
                FD.ptr = NULL; /* for safeness */
                foreach_item(start_item(L, FD.dir), FD.dir, elem_finder, &FD);
                ret = FD.ptr; /* cannot fail */
            }
        }
    }
    return ret;
}
コード例 #6
0
ファイル: tclist.c プロジェクト: BackupTheBerlios/tcforge-svn
int tc_list_foreach(TCList *L, TCListVisitor vis, void *userdata)
{
    return foreach_item(L->head, DIR_FORWARD, vis, userdata);
}