Exemple #1
0
int
link_list_test_main(int argc, char **argv)
{
        printf("----------------------------------------------\n");
        printf("starts to have a test of list.\n");
        printf("----------------------------------------------\n");
        link_list *list = link_list_create();
        link_list_insert_first(list, 1);
        link_list_insert_first(list, 2);
        link_list_insert_first(list, 3);
        link_list_insert_first(list, 4);
        link_list_append(list, 5);
        link_list_append(list, 6);
        link_list_delete(list, list->tail->prev->prev);
        link_list_insert_after(list, list->tail->prev->prev, 10);
        link_list_insert_before(list, list->tail->prev->prev, 9);
        link_list_traverse(list);
        /* printf("another is %d.\n", list->tail->prev->prev->next->data); */
        printf("ok, now length is %d.\n", list->length);
        printf("----------------------------------------------\n");
        printf("test is finished. everything is gone be alright.\n");
        printf("----------------------------------------------\n");
        printf("\n");

        return EXIT_SUCCESS;
}
Exemple #2
0
void
egl_state_create_cached_program (egl_state_t *egl_state,
                                 GLuint program_id)
{
    link_list_t **program_list = egl_state_get_shader_object_list (egl_state);
    link_list_append (program_list, program_new (program_id), program_destroy);
}
Exemple #3
0
void
cached_gl_context_add (EGLDisplay display, EGLConfig config, EGLContext context)
{
    link_list_t **dpys = cached_gl_displays ();
    if (! *dpys)
        return;

    link_list_t *dpy = *dpys;
    display_ctxs_surfaces_t *matched_dpy = NULL;
    while (dpy) {
        display_ctxs_surfaces_t *dpy_surfaces = (display_ctxs_surfaces_t *)dpy->data;
        if (dpy_surfaces->display == display) {
            matched_dpy = dpy_surfaces;
            break;
        }

        dpy = dpy->next;
    }

    if (matched_dpy) {
        context_t *c = malloc (sizeof (context_t));
        c->config = config;
        c->context = context;
        link_list_append (&(matched_dpy->contexts), (void *)c, free);
    }
}
Exemple #4
0
void
cached_gl_surface_add (EGLDisplay display, EGLConfig config, EGLSurface surface)
{
    link_list_t **dpys = cached_gl_displays ();
    if (! *dpys)
        return;

    link_list_t *dpy = *dpys;
    display_ctxs_surfaces_t *matched_dpy = NULL;
    while (dpy) {
        display_ctxs_surfaces_t *dpy_surfaces = (display_ctxs_surfaces_t *)dpy->data;
        if (dpy_surfaces->display == display) {
            matched_dpy = dpy_surfaces;
            break;
        }

        dpy = dpy->next;
    }

    if (matched_dpy) {
        surface_t *s = malloc (sizeof (surface_t));
        s->config = config;
        s->surface = surface;
        link_list_append (&(matched_dpy->surfaces), (void *)s, free);
    }
}
Exemple #5
0
void
egl_state_create_cached_shader (egl_state_t *egl_state,
                                GLuint shader_id)
{
    link_list_t **program_list = egl_state_get_shader_object_list (egl_state);
    shader_object_t *shader_object = (shader_object_t *)malloc (sizeof (shader_object_t));
    shader_object->id = shader_id;
    shader_object->type = SHADER_OBJECT_SHADER;
    link_list_append (program_list, shader_object, free);
}
Exemple #6
0
void
link_list_append_by_order(link_list *l, p_link_node p)
{
    p_link_node node, next, next_next;

    if (l->size > 0) {
        node = l->head.prev;
        next = node->next;
        while (node->data != NULL && after(node->key, p->key)) {
            next_next = next;
            next = node;
            node = node->prev;
        }
        node->next   = p;
        p->prev      = node;
        next->prev   = p;
        p->next      = next;
        l->size++;
    } else {
        link_list_append(l, p);
    }
}
Exemple #7
0
void
delay_table_add(uint64_t key, struct msg_server_s *msg)
{
    tc_pool_t           *pool;
    p_link_node          ln;
    delay_sess_t        *s;
    struct msg_server_s *cmsg;

    s = (delay_sess_t *) hash_find(table, key);
    if (s == NULL) {
        pool = tc_create_pool(TC_DEFAULT_POOL_SIZE, 0);

        if (pool != NULL) {

            s = (delay_sess_t *) tc_pcalloc(pool, sizeof(delay_sess_t));
            if (s != NULL) {
                s->key = key;
                s->pool = pool;
                s->msg_list = link_list_create(s->pool);
                s->evt = tc_event_add_timer(s->pool, OUTPUT_INTERVAL, s, 
                        tc_delay_del_obs);
                msg_ls_cnt++;
                hash_add(table, s->pool, key, s);
            } else {
                return;
            }
        } else {
            return;
        }
    }

    cmsg = copy_message(s->pool, msg);
    if (cmsg != NULL) {
        ln   = link_node_malloc(s->pool, (void *) cmsg);
        link_list_append(s->msg_list, ln);

        msg_item_cnt++;
    }
}
Exemple #8
0
/* append by order */
void
link_list_append_by_order(link_list *l, p_link_node p)
{
    p_link_node node, next;

    if (l->size > 0) {
        node = l->head.prev;
        next = node->next;
        /* find the node which key is less than the key of p */
        while (node->data != NULL && after(node->key, p->key)) {
            next = node;
            node = node ->prev;
        }
        node->next       = p;
        p->prev          = node;
        next->prev       = p;
        p->next          = next;
        l->size++;
    } else {
        link_list_append(l, p);
    }
}
Exemple #9
0
/* add message to delay table */
void
delay_table_add(uint64_t key, struct msg_server_s *msg)
{
    link_list           *msg_list;
    p_link_node          ln;
    struct msg_server_s *cmsg;

    msg_list = (link_list *) hash_find(table, key);
    if (msg_list == NULL) {
        msg_ls_cnt++;
        msg_list = link_list_create();
        hash_add(table, key, msg_list);
    }

    cmsg = copy_message(msg);
    if (cmsg != NULL) {
        ln   = link_node_malloc((void *) cmsg);
        link_list_append(msg_list, ln);

        msg_item_cnt++;
    }

    return;
}