Merge branch 'ralentit'
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/05/24 14:42:46 by hulamy #+# #+# */
|
||||
/* Updated: 2019/05/28 17:00:32 by hulamy ### ########.fr */
|
||||
/* Updated: 2019/06/01 13:46:56 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -51,6 +51,21 @@ int compare_tetri(t_fillist *tetri_a, t_fillist *tetri_b)
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
** Function that free the list->memory each time it's malloc
|
||||
*/
|
||||
|
||||
t_fillist *clean_list_memory(t_fillist *list, t_fillist *tmp)
|
||||
{
|
||||
while (tmp)
|
||||
{
|
||||
if (tmp->memory)
|
||||
free(tmp->memory);
|
||||
tmp = tmp->next;
|
||||
}
|
||||
return (list);
|
||||
}
|
||||
|
||||
/*
|
||||
** Test optimisation for not testing wrong maps when tetri are identical
|
||||
*/
|
||||
@@ -61,7 +76,8 @@ int check_same_tetri(t_fillist *list, int num)
|
||||
t_fillist *next_tetri;
|
||||
int i;
|
||||
|
||||
curr_tetri = list;
|
||||
curr_tetri = clean_list_memory(list, list);
|
||||
// curr_tetri = list;
|
||||
while (curr_tetri != NULL)
|
||||
{
|
||||
i = 0;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/05/27 13:46:29 by hulamy #+# #+# */
|
||||
/* Updated: 2019/06/01 14:00:58 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/05/29 16:25:52 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -30,7 +30,7 @@ t_fillist *print_tetri(t_fillist *list)
|
||||
print = tmp->tetribit;
|
||||
print <<= 16;
|
||||
print_sized_map(&print, tmp->width, tmp->height, tmp->letter);
|
||||
if (tmp->same)
|
||||
if (tmp->same && list->dope[1])
|
||||
{
|
||||
print = tmp->same->tetribit;
|
||||
print <<= 16;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/01 13:29:05 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/05/29 13:56:55 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/05/29 15:55:03 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -23,9 +23,7 @@ void print_error(char *str)
|
||||
}
|
||||
|
||||
/*
|
||||
** Function that display error message *s on fd
|
||||
** with more informations
|
||||
** and exit program
|
||||
** Function that display error message *s on fd with more informations
|
||||
*/
|
||||
|
||||
void print_error_extended(int error, int *dope)
|
||||
@@ -35,13 +33,16 @@ void print_error_extended(int error, int *dope)
|
||||
if (error == 1)
|
||||
print_error("error: File contains char other than '.','#' and '\\n'\n");
|
||||
if (error == 2)
|
||||
print_error("error: File contains more than 2 '\\n' in a row\n");
|
||||
print_error("error: File contains two tetriminos not"
|
||||
"separated by a '\\n'\n");
|
||||
if (error == 3)
|
||||
print_error("error: File contains more than 2 '\\n' in a row\n");
|
||||
if (error == 4)
|
||||
print_error("error: File contains less than 1 tetrimino "
|
||||
"or more than 26\n");
|
||||
if (error == 4)
|
||||
print_error("error: Tetrimino has more or less than 4 #\n");
|
||||
if (error == 5)
|
||||
print_error("error: Tetrimino has more or less than 4 #\n");
|
||||
if (error == 6)
|
||||
print_error("error: Tetrimino # are not all connected\n");
|
||||
print_error("error\n");
|
||||
}
|
||||
@@ -67,14 +68,14 @@ void check_file_errors(char *file, int *dope)
|
||||
else if (file[i] == '\n')
|
||||
line_nbr++;
|
||||
if (file[i] == '\n' && line_nbr % 5 == 0 && file[i-1] != '\n')
|
||||
print_error("error\n");
|
||||
print_error_extended(2, dope);
|
||||
if (file[i] == '\n' && file[i+1] != '\0' && \
|
||||
file[i+2] != '.' && file[i+2] != '#')
|
||||
print_error_extended(2, dope);
|
||||
print_error_extended(3, dope);
|
||||
i++;
|
||||
}
|
||||
if (line_nbr < 4 || line_nbr > 129)
|
||||
print_error_extended(3, dope);
|
||||
print_error_extended(4, dope);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -101,7 +102,7 @@ int check_tetri_errors(char *tetri)
|
||||
i++;
|
||||
}
|
||||
if (htg != 4 || dot != 12 || check_tetri_errors_proxy(tetri))
|
||||
return (4 + check_tetri_errors_proxy(tetri));
|
||||
return (5 + check_tetri_errors_proxy(tetri));
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/15 14:48:14 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/05/28 19:05:05 by hulamy ### ########.fr */
|
||||
/* Updated: 2019/06/01 13:32:38 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/13 12:09:46 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/05/28 18:36:35 by hulamy ### ########.fr */
|
||||
/* Updated: 2019/05/29 16:10:58 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -20,7 +20,7 @@ char *read_file(char *file)
|
||||
{
|
||||
char buf[BUFF_SIZE];
|
||||
int fd;
|
||||
size_t rv;
|
||||
int rv;
|
||||
int i;
|
||||
char *result;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: hulamy <hulamy@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/04/27 20:47:22 by hulamy #+# #+# */
|
||||
/* Updated: 2019/05/29 13:37:51 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/06/01 13:38:26 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -165,5 +165,6 @@ int search_map(t_fillist *list)
|
||||
map[num] = 0;
|
||||
i = fill_map(map, list, size++);
|
||||
}
|
||||
free(map);
|
||||
return (print_binary_map(map, size, list->dope));
|
||||
}
|
||||
|
||||
20
fillit.dSYM/Contents/Info.plist
Normal file
20
fillit.dSYM/Contents/Info.plist
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.apple.xcode.dsym.fillit</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>dSYM</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
4
fillit.h
4
fillit.h
@@ -6,7 +6,7 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/03/01 13:34:46 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/05/29 13:31:37 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/06/01 13:44:51 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -94,6 +94,7 @@ int print_flags_usage(void);
|
||||
*/
|
||||
int check_same_tetri(t_fillist *list, int num);
|
||||
int compare_tetri(t_fillist *tetri_a, t_fillist *tetri_b);
|
||||
t_fillist *clean_list_memory(t_fillist *list, t_fillist *tmp);
|
||||
int check_tetri_memory(t_fillist *list, int pos);
|
||||
|
||||
/*
|
||||
@@ -101,6 +102,7 @@ int check_tetri_memory(t_fillist *list, int pos);
|
||||
*/
|
||||
int main(int argc, char **argv);
|
||||
int *create_dope(char *av, int mdp);
|
||||
void clean_list(t_fillist *list, t_fillist *tmp);
|
||||
int is_mdp(int ac, char **av);
|
||||
|
||||
/*
|
||||
|
||||
21
main.c
21
main.c
@@ -6,7 +6,7 @@
|
||||
/* By: vmanzoni <vmanzoni@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/02/12 13:20:48 by vmanzoni #+# #+# */
|
||||
/* Updated: 2019/05/29 13:27:14 by vmanzoni ### ########.fr */
|
||||
/* Updated: 2019/06/01 13:41:46 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -66,6 +66,22 @@ int is_mdp(int ac, char **av)
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
** Function that free the list
|
||||
*/
|
||||
|
||||
void clean_list(t_fillist *list, t_fillist *tmp)
|
||||
{
|
||||
tmp = list;
|
||||
while (list)
|
||||
{
|
||||
list = tmp->next;
|
||||
free(tmp->memory);
|
||||
free(tmp);
|
||||
tmp = list;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Main function
|
||||
*/
|
||||
@@ -87,8 +103,11 @@ int main(int ac, char **av)
|
||||
check_file_errors(input, dope);
|
||||
size = parse_input(input, &list, dope);
|
||||
print_final_map(list, size);
|
||||
free(input);
|
||||
clean_list(list, list);
|
||||
}
|
||||
else
|
||||
print_error("usage: Please submit a file.\n> ./fillit file.fillit\n");
|
||||
free(dope);
|
||||
return (0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user