Пример #1
0
static void free_streams(gavl_edl_stream_t * s, int len)
  {
  int i;
  for(i = 0; i < len; i++)
    {
    if(s[i].segments) free_segments(s[i].segments, s[i].num_segments);
    }
  free(s);
  }
Пример #2
0
void clean_up()
{
	free_segments(um->memory);
	free_IDs(um->unmapped_IDs);
	UArray_free(&um->registers);	

	FREE(um);

	return;
}
Пример #3
0
int main(void){
	//tests();
	POLYGON temp;
	assert(get_size(&temp.size_points)==TRUE);
	alloc_points(&temp.max_of_x,&temp.points,temp.size_points);
	temp.segments=create_segments(temp.size_points);
	add_segments(temp.points,temp.segments,temp.size_points);
	draw_polygon(temp);
	triangulal_polygol(temp); 
	printf("Potrzeba %d straznikow\n",coloring_sl(temp.points,temp.segments,temp.size_points));
	print_colors(temp.points,temp.size_points);
	draw_polygon(temp);
	free_segments(temp.segments,temp.size_points);
	free_points(temp.points);
	return EXIT_SUCCESS;
}
Пример #4
0
void Stack<E, F>::clear(bool clear_cache)
{
  free_segments(_cur_seg);
  if (clear_cache) free_segments(_cache);
  reset(clear_cache);
}
Пример #5
0
/*
 * This function is called from two paths.
 * One is garbage collection and the other is SSR segment selection.
 * When it is called during GC, it just gets a victim segment
 * and it does not remove it from dirty seglist.
 * When it is called from SSR segment selection, it finds a segment
 * which has minimum valid blocks and removes it from dirty seglist.
 */
static int get_victim_by_default(struct f2fs_sb_info *sbi,
                                 unsigned int *result, int gc_type, int type, char alloc_mode)
{
    struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
    struct victim_sel_policy p;
    unsigned int secno, max_cost;
    int nsearched = 0;

    p.alloc_mode = alloc_mode;
    select_policy(sbi, gc_type, type, &p);

    p.min_segno = NULL_SEGNO;
    p.min_cost = max_cost = get_max_cost(sbi, &p);

    mutex_lock(&dirty_i->seglist_lock);

    if (p.alloc_mode == LFS && gc_type == FG_GC) {
        p.min_segno = check_bg_victims(sbi);
        if (p.min_segno != NULL_SEGNO)
            goto got_it;
    }

    while (1) {
        unsigned long cost;
        unsigned int segno;

        segno = find_next_bit(p.dirty_segmap,
                              TOTAL_SEGS(sbi), p.offset);
        if (segno >= TOTAL_SEGS(sbi)) {
            if (sbi->last_victim[p.gc_mode]) {
                sbi->last_victim[p.gc_mode] = 0;
                p.offset = 0;
                continue;
            }
            break;
        }
        p.offset = ((segno / p.ofs_unit) * p.ofs_unit) + p.ofs_unit;
        secno = GET_SECNO(sbi, segno);

        if (sec_usage_check(sbi, secno))
            continue;
        if (gc_type == BG_GC && test_bit(secno, dirty_i->victim_secmap))
            continue;

        cost = get_gc_cost(sbi, segno, &p);

        if (p.min_cost > cost) {
            p.min_segno = segno;
            p.min_cost = cost;
        }

        if (cost == max_cost)
            continue;

        if (nsearched++ >= MAX_VICTIM_SEARCH) {
            sbi->last_victim[p.gc_mode] = segno;
            break;
        }
    }
    if (p.min_segno != NULL_SEGNO) {
got_it:
        if (p.alloc_mode == LFS) {
            secno = GET_SECNO(sbi, p.min_segno);
            if (gc_type == FG_GC)
                sbi->cur_victim_sec = secno;
            else
                set_bit(secno, dirty_i->victim_secmap);
        }
        *result = (p.min_segno / p.ofs_unit) * p.ofs_unit;

        trace_f2fs_get_victim(sbi->sb, type, gc_type, &p,
                              sbi->cur_victim_sec,
                              prefree_segments(sbi), free_segments(sbi));
    }
    mutex_unlock(&dirty_i->seglist_lock);

    return (p.min_segno == NULL_SEGNO) ? 0 : 1;
}