Bonjour à toutes et à tous,
Pour mon programme, j'ai besoin d'une structure contenant une autre structure et deux tableaux de structures.
J'ai plusieurs questions :
- le nombre de structures Picture dans Metadata dépend du fichier traîté, comment puis-je faire pour l'allocation de mémoire?
- on ne connais qu'à l'exécution la taille des champs 'field' et 'value', comment puis-je faire pour l'allocation de mémoire?
- comment libérer proprement la mémoire allouée?
Voici mon code :
Merci d'avance pour votre aide.
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 typedef struct { char *mime_type; char *description; int width; int height; int depth; int colors; int data_length; char *data; } Picture; typedef struct { unsigned int min_blocksize; unsigned int max_blocksize; unsigned int min_framesize; unsigned int max_framesize; unsigned int sample_rate; unsigned int channels; unsigned int bits_per_sample; unsigned long int total_samples; char md5sum[16]; } Info; typedef struct { char *field; char *value; } Comment; typedef struct { Info info; Comment *comments; Picture *pictures } Metadata;
Edit : message corrigé.
Partager