Skip to content

Commit

Permalink
update lst->content, (char *) -> (int *)
Browse files Browse the repository at this point in the history
  • Loading branch information
rask24 committed Jan 15, 2024
1 parent b8e3c58 commit 074a918
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
9 changes: 7 additions & 2 deletions src/generate_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/11 19:04:40 by reasuke #+# #+# */
/* Updated: 2024/01/12 15:42:34 by reasuke ### ########.fr */
/* Updated: 2024/01/15 12:56:26 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -93,13 +93,18 @@ t_list *generate_stack(int argc, char **argv)
t_list *stack;
int *compressed_array;
int i;
int *ptr;

compressed_array = _coordinate_compression(argc, argv);
i = 0;
stack = NULL;
while (i < argc - 1)
{
ft_lstadd_back(&stack, ft_lstnew(ft_itoa(compressed_array[i])));
ptr = ft_calloc(1, sizeof(int));
if (!ptr)
exit_with_error();
*ptr = compressed_array[i];
ft_lstadd_back(&stack, ft_lstnew(ptr));
i++;
}
free(compressed_array);
Expand Down
12 changes: 6 additions & 6 deletions src/nano_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/12 15:58:22 by reasuke #+# #+# */
/* Updated: 2024/01/12 16:17:00 by reasuke ### ########.fr */
/* Updated: 2024/01/15 12:58:12 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -17,8 +17,8 @@ static void _handle_2(t_list *stack)
int first;
int second;

first = ft_atoi(stack->content);
second = ft_atoi(stack->next->content);
first = *(int *)stack->content;
second = *(int *)stack->next->content;
if (first > second)
ft_putendl_fd("sa", STDOUT_FILENO);
}
Expand All @@ -29,9 +29,9 @@ static void _handel_3(t_list *stack)
int second;
int third;

first = ft_atoi(stack->content);
second = ft_atoi(stack->next->content);
third = ft_atoi(stack->next->next->content);
first = *(int *)stack->content;
second = *(int *)stack->next->content;
third = *(int *)stack->next->next->content;
if (first == 2 && second == 1 && third == 3)
ft_putendl_fd("sa", STDOUT_FILENO);
else if (first == 3 && second == 2 && third == 1)
Expand Down

0 comments on commit 074a918

Please sign in to comment.