Пример #1
0
internal void 	node_cache_add_to_bucket( node_cache* nc, node* n ) {

	u32 node_index = index_from_node_pointer( nc, n );
	entry* bucket_entry = &nc->bucket_entries[node_index];

	printf("Bucket entry %p\n", (void*)bucket_entry);

	bucket_entry->node = n;
	u32 index = bucket_index_from_node( n );
	printf("Adding node %d to bucket %d\n", n->id, index);
	nc->bucket[index] = dl_list_insert( nc->bucket[index], bucket_entry );

}
Пример #2
0
internal entry* node_cache_add_to_list( node_cache* nc, node* n, u8 list_index ) {

	u32 node_index = index_from_node_pointer( nc, n );
	entry* list_entry = &nc->entries[node_index];

	// wrap it in an entry in the appropriate list (index/key, clean/dirty)
	printf("List entry %p\n", (void*)list_entry);
	list_entry->node = n;
	nc->list[list_index] = dl_list_insert( nc->list[list_index], list_entry );
	dl_list_debug( nc->list[list_index] );

	return list_entry;
}
Пример #3
0
/* add page n to the page history */
void page_history_insert(int n)
{
    struct page_history *item = NULL;
    static char *current_filename = NULL;
    static size_t filename_idx = 0; /* index of current filename */

#if DEBUG
    fprintf(stderr, "inserting into history: %d\n", n);
#endif
    page_history_show(m_page_history_head, m_page_history);
    /* do nothing if no history is used */
    if (resource.page_history_size == 0)
	return;

    if (m_page_history_head == NULL)
	m_page_history_head = m_page_history;
    
    item = xmalloc(sizeof *item);
    /* first call, or filename changed -> update file_list */
    if (current_filename == NULL || strcmp(current_filename, globals.dvi_name) != 0) {
	size_t i;
	current_filename = xstrdup(globals.dvi_name);

	for (i = 0; i < m_filename_size; i++) {
#if DEBUG
	    fprintf(stderr, "comparing %d: |%s|%s|\n", i, current_filename, m_filename_list[i]);
#endif
	    if (strcmp(current_filename, m_filename_list[i]) == 0) { /* found */
		filename_idx = i;
		break;
	    }
	}

	if (i >= m_filename_size) { /* not found, insert into file list */
	    m_filename_list = xrealloc(m_filename_list, (m_filename_size + 1) * sizeof *m_filename_list);
	    m_filename_list[m_filename_size] = filename_append_dvi(current_filename);
	    filename_idx = m_filename_size++;
#if DEBUG
	    fprintf(stderr, "NEW file %d: %s\n", filename_idx, current_filename);
#endif
	}
    }
    
#if DEBUG
    fprintf(stderr, "-------- %d >= %d?\n", m_page_history_length, resource.page_history_size - 1);
#endif
    if (m_page_history_length >= resource.page_history_size - 1) { /* truncate history */
	free(m_page_history_head->item);
	m_page_history_head = dl_list_truncate_head(m_page_history_head);
    }
    else {
	m_page_history_length++;
    }
    
    item->pageno = n;
    item->file_idx = filename_idx;
    
#if DEBUG
    fprintf(stderr, "inserting %d\n", item->pageno);
#endif
    m_page_history = dl_list_insert(m_page_history, item);
    m_page_history_currpos++;

#if DEBUG
    fprintf(stderr, "head: %p, curr: %p\n", (void *)m_page_history_head, (void *)m_page_history);
#endif
    page_history_show(m_page_history_head, m_page_history);
    page_history_update_toolbar_navigation();
}