Exemple #1
0
void	error_fn3(char *reason, t_stack *stack)
{
	if (stack->a)
		ft_memdel((void**)&stack->a);
	if (stack->arg > 2)
		ft_strdel(&(stack->str));
	ft_memdel((void**)&stack);
	ft_error(reason);
}
Exemple #2
0
void		free_struct(t_norme *s)
{
	ft_memdel((void**)&s->old);
	ft_memdel((void**)&s->pwd);
	ft_memdel((void**)&s->str);
	if (s->copy)
		free_double_array(s->copy);
	ft_memdel((void**)&s);
}
Exemple #3
0
void	error_fn2(t_stack *stack)
{
	if (stack->a)
		ft_memdel((void**)&stack->a);
	if (stack->arg > 2)
		ft_strdel(&(stack->str));
	ft_memdel((void**)&stack);
	ft_putendl_fd("Error", 2);
	exit(EXIT_FAILURE);
}
void	ft_clear_mlx(t_mlx *mlx)
{
	if (!mlx)
		return ;
	mlx_destroy_image(mlx->p_mlx, mlx->mlx_img->p_img);
	ft_memdel((void **)&mlx->mlx_img);
	mlx_clear_window(mlx->p_mlx, mlx->p_win);
	mlx_destroy_window(mlx->p_mlx, mlx->p_win);
	ft_memdel((void **)&mlx);
}
Exemple #5
0
static void	draw_ui(char *score, t_vect2i s)
{
	char	*tmp;

	tmp = ft_strjoin("Score : ", score);
	ft_memdel((void**)&score);
	mvprintw(2, s.x * 2 - (ft_strlen(tmp) / 2), tmp);
	ft_memdel((void**)&tmp);
	mvprintw(s.y * 4 + 4, s.x * 2 - 9, "Press <Esc> to quit");
}
Exemple #6
0
char	*free_join(char *s1, char *s2, int lib)
{
	char	*tmp;

	tmp = ft_strjoin(s1, s2);
	if (s1 && (lib == 3 || lib == 2))
		ft_memdel((void **)&s1);
	if (s2 && (lib == 3 || lib == 1))
		ft_memdel((void **)&s2);
	return (tmp);
}
Exemple #7
0
void	error_fn4(t_stack *stack, char *line)
{
	ft_strdel(&line);
	ft_memdel((void**)&stack->a);
	ft_memdel((void**)&stack->b);
	if (stack->arg > 2)
		ft_strdel(&(stack->str));
	ft_memdel((void**)&stack);
	ft_putendl_fd("Error", 2);
	exit(EXIT_FAILURE);
}
Exemple #8
0
void			ft_free_ms(t_ms *ms)
{
	int			i;

	i = 0;
	while (ms->path[i])
		ft_memdel((void **)&ms->path[i++]);
	ft_memdel((void **)&ms->path);
	ft_memdel((void **)&ms->pwd);
	ft_memdel((void **)&ms->oldpwd);
	ft_memdel((void **)&ms->prompt);
}
Exemple #9
0
void		free_cmd(char **cmd)
{
	int			i;

	i = 0;
	while (cmd[i])
	{
		ft_memdel((void**)&cmd[i]);
		i++;
	}
	ft_memdel((void**)&cmd);
}
Exemple #10
0
void		free_double_array(char **arr)
{
	int		i;

	i = 0;
	while (arr[i] != NULL)
	{
		ft_memdel((void**)&arr[i]);
		i++;
	}
	ft_memdel((void**)&arr);
}
Exemple #11
0
void			free_shell(t_shell **shell)
{
    if (shell && *shell)
    {
        ft_memdel((void **)&(*shell)->prompt);
        ft_deltab(&((*shell)->envc));
        ft_deltab(&(*shell)->cmd);
        ft_deltab(&(*shell)->path);
        free_env(&(*shell)->env);
        ft_memdel((void **)shell);
    }
}
Exemple #12
0
void			ft_dellistelmt(t_select **list)
{
	t_select	*tmp;

	if ((tmp = *list))
	{
		tmp->next->prev = tmp->prev;
		tmp->prev->next = tmp->next;
		ft_memdel((void **)&tmp->str);
		ft_memdel((void **)&tmp);
	}
}
Exemple #13
0
static void		join_rest(char **rest, char *buf)
{
	char *tmp;

	tmp = ft_strnew(ft_strlen(*rest) + ft_strlen(buf));
	ft_strcat(tmp, *rest);
	ft_strcat(tmp, buf);
	ft_memdel((void**)&*rest);
	*rest = ft_strnew(ft_strlen(tmp));
	ft_strcpy(*rest, tmp);
	ft_memdel((void**)&tmp);
}
Exemple #14
0
void		cmd_destroy(char ***at)
{
	char	**cp;

	cp = *at;
	while (*cp)
	{
		ft_memdel((void **)cp);
		cp++;
	}
	ft_memdel((void **)at);
}
Exemple #15
0
static t_read		*ft_freeread(t_read *red, t_read *prev, t_read **start)
{
	if (!prev)
		*start = red->next;
	else
		prev->next = red->next;
	ft_memdel((void**)&red->read);
	ft_memdel((void**)&red);
	if (!prev)
		return (*start);
	else
		return (prev->next);
}
Exemple #16
0
static void		lst_del_cmd(t_cmd **ptr)
{
	t_cmd	*cmd;

	cmd = *ptr;
	while (cmd)
	{
		*ptr = C_NXT;
		ft_memdel((void**)&C_CMD);
		ft_memdel((void**)&cmd);
		cmd = *ptr;
	}
}
Exemple #17
0
static void	free_cmd(\
			t_cmd *cmd)
{
	char	**cp;

	cp = cmd->arg_v;
	while (*cp)
	{
		ft_memdel((void **)cp);
		cp++;
	}
	ft_memdel((void **)&cmd->arg_v);
}
Exemple #18
0
void		ft_lstdelone(t_list **alst, void (*del)(void *, size_t))
{
	t_list		*tmp;

	if (alst && *alst)
	{
		tmp = (*alst)->next;
		del((*alst)->content, (*alst)->content_size);
		ft_memdel(&((*alst)->content));
		ft_memdel((void **)alst);
		*alst = tmp;
	}
	return ;
}
Exemple #19
0
void		env_envdel(t_data *d)
{
	int		i;

	i = 0;
	while (d && d->cenv && d->cenv[i])
	{
		if (d && d->cenv && d->cenv[i])
			ft_memdel((void **)&d->cenv[i]);
		i++;
	}
	if (d && d->cenv)
		ft_memdel((void **)&d->cenv);
}
Exemple #20
0
void				ft_lstline_del(t_lstline **begin)
{
	t_lstline	*list;

	list = *begin;
	while (list)
	{
		*begin = list->next;
		ft_memdel((void **)&list->line);
		ft_memdel((void **)&list);
		list = *begin;
	}
	*begin = NULL;
}
Exemple #21
0
void			ft_hdel(t_htable **table)
{
	t_hnode	**bucket;

	bucket = (*table)->bucket;
	while ((*table)->bucket_size--)
	{
		if (*bucket)
			del_list(*table, *bucket);
		bucket++;
	}
	ft_memdel((void *)&(*table)->bucket);
	ft_memdel((void *)table);
}
Exemple #22
0
void		free_tabtab(char **tab)
{
	int	i;

	i = 0;
	if (tab == NULL)
		return ;
	while (tab[i] != NULL)
	{
		ft_memdel((void **)&tab[i]);
		++i;
	}
	ft_memdel((void **)&tab);
}
Exemple #23
0
static void	ft_delete_face(t_obj *o)
{
	int		y;

	y = 0;
	if (!o->f)
		return ;
	while (y < o->nb_f)
	{
		ft_memdel((void **)&o->f[y]);
		y++;
	}
	ft_memdel((void **)&o->f);
}
Exemple #24
0
void	destroy_connections(t_connections *connections)
{
	t_connections *tmp;
	t_connections *prev;

	tmp = connections;
	prev = NULL;
	while (tmp)
	{
		ft_memdel((void**)&prev);
		prev = tmp;
		tmp = tmp->next;
	}
	ft_memdel((void**)&prev);
}
Exemple #25
0
void	del_list(t_list *list)
{
	t_elem	*elem;
	t_elem	*tmp;

	elem = list->first;
	while (elem)
	{
		tmp = elem;
		elem = elem->next;
		ft_memdel(&tmp->data);
		ft_memdel((void **)&tmp);
	}
	ft_memdel((void **)&list);
}
Exemple #26
0
static void		lst_del_ant(t_env *env, t_ant **ant, t_ant **prv)
{
	if (*ant == E_ANT)
	{
		E_ANT = (*ant)->nxt;
		ft_memdel((void**)ant);
		*prv = *ant = E_ANT;
	}
	else
	{
		(*prv)->nxt = (*ant)->nxt;
		ft_memdel((void**)ant);
		*ant = (*prv)->nxt;
	}
}
Exemple #27
0
int			ft_parser_print_err(char c)
{
	char	*tmp;
	char	*tmp2;
	char	ch[2];

	ch[0] = c;
	ch[1] = '\0';
	tmp = ft_strjoin("Parse error near '", ch);
	tmp2 = ft_strjoin(tmp, "'");
	ft_memdel((void **)&tmp);
	ft_err(tmp2);
	ft_memdel((void **)&tmp2);
	return (ERR);
}
Exemple #28
0
static void		cut_selection(int begin, int end, t_it *it)
{
	char	*first;
	char	*second;
	int		lenght;

	lenght = ft_strlen(it->line) - (end - it->offset);
	second = ft_strsub(it->line, end + 1, lenght - 1);
	first = ft_memalloc((sizeof(char) * begin) + 1);
	ft_strncpy(first, it->line, begin);
	ft_memdel((void**)&it->line);
	it->line = ft_strjoin(first, second);
	ft_memdel((void**)&first);
	ft_memdel((void**)&second);
}
Exemple #29
0
void		free_env(char *path, char **path_env)
{
	int		i;
	int		j;

	i = 0;
	j = 0;
	ft_memdel((void**)&path);
	while (path_env[i])
	{
		ft_memdel((void**)&path_env[i]);
		i++;
	}
	ft_memdel((void**)&path_env);
}
Exemple #30
0
void		send_client(t_fds *fds, t_server *srv, int tim)
{
	int			n;
	char		*cmd;
	t_gfx		*gfx;
	t_client	*clt;

	cmd = time_lapse(fds, srv, tim);
	while (tim >= 0 && --fds->max > 0 && !(n = 0))
	{
		if (!(clt = srv->clt) && !FD_ISSET(fds->max, &fds->wr))
			continue ;
		while (clt != NULL && clt->socket != fds->max)
			clt = clt->next;
		gfx = srv->gfx;
		while (gfx != NULL && gfx->socket != fds->max)
			gfx = gfx->next;
		if (!incant_process(clt, srv) || (!clt && gfx))
			cmd = !clt ? ring_send(srv, gfx->ring) : ring_send(srv, clt->ring);
		while (cmd && n < (clt ? 13 : 10) && strncmp(cmd, (!clt ? g_gfx_cmd[n] :
				g_clt_cmd[n]), strlen(!clt ? g_gfx_cmd[n] : g_clt_cmd[n])) != 0)
			n++;
		(!clt && cmd && 0 <= n && n < 11) ? g_tfg[n](fds, srv, gfx, cmd) : NULL;
		if ((n = time_action((save_cur_cmd(clt, cmd, n) ? n : 13), clt, srv)))
			g_tfc[n - 1](fds, srv, clt, cmd);
		ft_memdel((void **)&cmd);
	}
}