c'est moche mais fix

This commit is contained in:
Camille Chauvet 2023-01-24 15:29:14 +01:00
parent 3b80be7c0f
commit 0bee795dac
5 changed files with 4 additions and 8 deletions

BIN
.nfs000000000a01060e0000009c Executable file

Binary file not shown.

View File

@ -24,6 +24,7 @@ void ft_char2signal(int pid, char c)
kill(pid, SIGUSR2); kill(pid, SIGUSR2);
else else
kill(pid, SIGUSR1); kill(pid, SIGUSR1);
usleep(5);
i--; i--;
} }
} }

Binary file not shown.

View File

@ -14,6 +14,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include "../libftx/libftx.h" #include "../libftx/libftx.h"
#define ALLLOC_SIZE 2000000
char *ft_tab_int_to_str(int *tab, size_t len) char *ft_tab_int_to_str(int *tab, size_t len)
{ {
@ -51,26 +52,20 @@ int ft_is_finished(int *tab, size_t len)
void handler(int num) void handler(int num)
{ {
static int *tab = NULL; static int tab[ALLLOC_SIZE];
static size_t len = 0; static size_t len = 0;
char *str; char *str;
tab = ft_realloc(tab, len, len + 2, sizeof(int));
if (tab == NULL)
return ;
if (len == 0) if (len == 0)
tab[0] = num; tab[0] = num;
else else
tab[len] = num == tab[0]; tab[len] = num == tab[0];
ft_printf("tab[%d] = %d\n", len, tab[len]);
len++; len++;
if (ft_is_finished(tab + 1, len - 1)) if (ft_is_finished(tab + 1, len - 1))
{ {
str = ft_tab_int_to_str(tab + 1, len - 1); str = ft_tab_int_to_str(tab + 1, len - 1);
free(tab); ft_printf("%s", str);
ft_printf("%s\n", str);
free(str); free(str);
tab = NULL;
len = 0; len = 0;
} }
} }

Binary file not shown.