Bonjour
J'avais créé des fonctions d'allocation pour éviter de refaire a chaque fois les test de succés comme ca :
Presenté comme ca, pas grand interet mais pour en allouer plein d'un coup c'est plus pratique.
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 //Pour un int par exemple int allocation_int(int ** pt) { *pt = malloc(TAILLE*sizeof(int)); if(!(*pt)){ trace("Error : Allocation memoire\n"); return 0; } return 1; } //et je l'apelle comme ca : int * test, *test2; if(!allocation_int(&test) || !allocation_int(&test2)){ ... }
Je voudrais en faire un générique et j'ai fait :
Et j'obtient cette erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 int allocation_type (void ** pt) { *pt = malloc(TAILLE*sizeof(**pt)); if(!(*pt)){ trace("Error : Allocation memoire\n"); return 0; } return 1; } //que j'apelle comme ca : if(!allocation_type(&test)
Pourquoi?warning: passing arg 1 of `allocation_type' from incompatible pointer type
merci
Partager