Hello !
Donc voila je viens poster suite a un petit probleme ! Je rencontre un *** glibc detected *** mais je ne comprends strictement pas pourquoi
En fait void create_wordtab(t_file *f); va me creer et remplir un tableau de pointeur sur char. La largeur doit etre de la valeur f->width_lines et la heuteur f->nb_lines. Cette fonction plante au moment du
f->tab = malloc(sizeof(*(f->tab)) * (f->nb_lines + 1)); et renvoie *** glibc detected *** ./xxx: malloc: top chunk is corrupt: 0x09d45020 ***
Donc si qqn pouvait me dire d'ou cela venait, je l'en remercie !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63 typedef struct s_quares { int coor_x; int coor_y; int size; struct s_quares *next; } t_squares; typedef struct s_file { int fd; int nb_lines; int width_lines; int buffer_width; int buffer_position; char buffer[BUFFER_SIZE]; char **tab; t_squares *begin; } void create_wordtab(t_file *f) { int x; int y; x = 0; y = 0; f->tab = malloc(sizeof(*(f->tab)) * (f->nb_lines + 1)); /* ERROR ! */ if (f->tab == NULL) { my_putstr(MALLOC_ERROR); exit(EXIT_FAILURE); } f->tab[f->nb_lines] = NULL; /* ... */ } void init_wordtab(t_file *f, char *path) { f->fd = open(path, O_RDONLY); if (f->fd <= 0) { my_putstr(OPEN_ERROR); exit(EXIT_FAILURE); } create_wordtab(f); close(f->fd); print_wordtab(f->tab); } void do_prog(char *path) { t_file *f; f = init_f(); if (f == NULL) { my_putstr(MALLOC_ERROR); DEBUG_INFO; exit(EXIT_FAILURE); } get_dimensions(f, path); init_wordtab(f, path); }
Partager