コード例 #1
0
ファイル: recursive.c プロジェクト: Lolhomme/Fillit
int			recursive(t_map *map, t_trimino *tetrimino)
{
	int	newpos;

	if (protect_stack(map, tetrimino))
		return (1);
	newpos = find_next_pos(map, tetrimino);
	if (newpos)
	{
		if (newpos <= map->target)
		{
			if (tetrimino->next)
				return (recursive(map, tetrimino->next));
		}
		else
			return (recursive(map, tetrimino));
	}
	else if (tetrimino->prev)
	{
		map_unprint_tetrimino(map, tetrimino);
		return (recursive(map, tetrimino->prev));
	}
	else if (!tetrimino->prev)
		return (1);
	return (0);
}
コード例 #2
0
void alloc_prolog_memory(prolog_engine *pe, size_t stack_size, size_t heap_size)
{

	pe->stack_size = stack_size;
	pe->heap_size = heap_size;
	pe->memory_base = (PCell *)safe_mmap(0, (heap_size + stack_size)*sizeof(PCell) + heap_size/8, 0);
	pe->mark_area = pe->memory_base + heap_size + stack_size;
	pe->stack_max = pe->memory_base;
	pe->stack_base = pe->heap_base = pe->stack_max + stack_size;
	pe->trail_base = pe->globals_top = pe->globals_base = pe->heap_base + heap_size - 1;
	pe->globals_free_list.uint = MMK_INT(-1);

	protect_stack(pe);
}