finished transition to t_psdata format corrected some pointer formating started testing on parser function: - weird valgrind errors about uninitialised values - some read/write/free errors still hanging around ** END TRANSMISSION **
47 lines
1.4 KiB
C
47 lines
1.4 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ps_rot.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2019/02/21 16:07:55 by tmaze #+# #+# */
|
|
/* Updated: 2019/02/24 13:56:33 by tmaze ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "push_swap.h"
|
|
|
|
void ps_rot(t_psdata *data, char c)
|
|
{
|
|
t_stack *s;
|
|
t_stack *tmp;
|
|
t_stack *ind;
|
|
size_t size;
|
|
|
|
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 = ps_stkpop(data, c);
|
|
ind = s;
|
|
while (ind->next != NULL)
|
|
ind = ind->next;
|
|
ind->next = tmp;
|
|
}
|
|
else if (s != NULL && size == 2)
|
|
ps_swap(data, c);
|
|
}
|
|
|
|
void ps_rrot(t_psdata *data)
|
|
{
|
|
ps_rot(data, 'a');
|
|
ps_rot(data, 'b');
|
|
}
|