started conversion of functions to data structure system still WIP added first iteration of int parser does not check for int overflow
42 lines
1.3 KiB
C
42 lines
1.3 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ps_swap.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2019/02/21 14:06:40 by tmaze #+# #+# */
|
|
/* Updated: 2019/02/23 15:24:12 by tmaze ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "push_swap.h"
|
|
|
|
void ps_swap(t_psdata *data, char c)
|
|
{
|
|
t_stack *s;
|
|
size_t size;
|
|
int tmp;
|
|
|
|
if (c == 'a')
|
|
s = data->a;
|
|
if (c == 'a')
|
|
size = data->size_a;
|
|
else if (c == 'b')
|
|
s = data->b;
|
|
if (c == 'b')
|
|
size = data->size_b;
|
|
if (*s != NULL && size >= 2)
|
|
{
|
|
tmp = (*s)->nb;
|
|
(*s)->nb = (*s)->next->nb;
|
|
(*s)->next->nb = tmp;
|
|
}
|
|
}
|
|
|
|
void ps_sswap(t_psdata *data)
|
|
{
|
|
ps_swap(data, 'a');
|
|
ps_swap(data, 'b');
|
|
}
|