static void creat_window(t_init *t_init_mlx) { t_init_mlx->win = mlx_new_window(t_init_mlx->mlx, WIDTH, HEIGHT, WIN_N); tryalloc(t__mlx->win); t_init_mlx->mypic = mlx_new_image(t_init_mlx->mlx, WIDTH, HEIGHT); tryalloc(t__mlx->mypic); dot_printing(t_init_mlx); }
void init_fdf(const char *str, t_init *t_init_mlx) { int **numberarray; t_map *number_map; int fd; fd = open(str, O_RDONLY); number_map = get_struct_value(get_number(open(str, O_RDONLY))); tryalloc(number_map); t_init_mlx = (t_init*)ft_memalloc(sizeof(t_init)); tryalloc(t_init_mlx); t_init_mlx->nbr_map = number_map; t_init_mlx->wid = WIDTH; t_init_mlx->hei = HEIGHT; print_map_number(t_init_mlx->nbr_map); t_init_mlx->mlx = mlx_init(); creat_window(t_init_mlx); mlx_mouse_hook(t_init_mlx->win, my_mouse_func, &t_init_mlx); mlx_key_hook(t_init_mlx->win, my_key_func, &t_init_mlx); mlx_loop(t_init_mlx->mlx); }
/* * Someone couldn't find pages of the given size index and color. * (color may be NOCOLOR if the caller is trying to get any page * and is desperate). * Many processes may be calling this at the same time, * The first one operates as a pager and does what it can. */ void kickpager(int pgszi, int color) { Proc *up = externup(); Pgsza *pa; if(DBGFLG>1) DBG("kickpager() %#p\n", up); if(waserror()) panic("error in kickpager"); qlock(&pagerlck); pa = &pga.pgsza[pgszi]; /* * 1. did anyone else release one for us in the mean time? */ if(hascolor(pa->head, color)) goto Done; /* * 2. try allocating from physical memory */ tryalloc(pgszi, color); if(hascolor(pa->head, color)) goto Done; /* * If pgszi is <= text page size, try releasing text pages. */ if(sys->pgsz[pgszi] <= 2*MiB){ pstats.ntext++; DBG("kickpager() up %#p: reclaiming text pages\n", up); pageouttext(pgszi, color); tryalloc(pgszi, color); if(hascolor(pa->head, color)){ DBG("kickpager() found %uld free\n", pa->freecount); goto Done; } } /* * Try releasing memory from bigger pages. */ pstats.nbig++; freepages(pgszi+1, 1); tryalloc(pgszi, color); if(hascolor(pa->head, color)){ DBG("kickpager() found %uld free\n", pa->freecount); goto Done; } /* * Really the last resort. Try releasing memory from all pages. */ pstats.nall++; DBG("kickpager() up %#p: releasing all pages\n", up); freepages(0, 0); tryalloc(pgszi, color); if(pa->freecount > 0){ DBG("kickpager() found %uld free\n", pa->freecount); goto Done; } /* * What else can we do? * But don't panic if we are still trying to get memory of * a particular color and there's none. We'll retry asking * for any color. */ if(color == NOCOLOR) panic("kickpager(): no physical memory"); Done: poperror(); qunlock(&pagerlck); if(DBGFLG>1) DBG("kickpager() done %#p\n", up); }