erreure de insertSucc corrigee, partie 3 ok

master
parent 45ba57195a
commit 89fb00f02c

BIN
SAE2

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -121,13 +121,13 @@ Precedence *loadPrec(int *tmax, int *tlog)
prec=fopen("files/precedences.txt", "r");
(*tmax)=5;
(*tlog)=0;
if (prec == NULL)
if (!prec)
{
printf("\033[0;31mErreur: \033[0mouverture de 'precedence.txt'\n");
exit(1);
}
tabP = (Precedence *)malloc((*tmax) * sizeof(Precedence));
if (tabP == NULL)
if (!tabP)
{
printf("\033[0;31mErreur: \033[0mmalloc loadPrec\n");
exit(1);
@ -140,7 +140,7 @@ Precedence *loadPrec(int *tmax, int *tlog)
{
(*tmax)+=5;
s = (Precedence *)realloc(tabP, (*tmax) * sizeof(Precedence));
if (s==NULL)
if (!s)
{
printf("\033[0;31mErreur: \033[0mreallocation pour fichier précédence\n");
exit(1);
@ -169,8 +169,9 @@ Tache **loadTaches(Offre *tabTravaux[])
Precedence *prec;
int i, tmaxPrec, tlogPrec;
Tache *t, **tabTache;
tabTache = (Tache **)malloc(8*sizeof(Tache *));
if (tabTache == NULL)
tabTache = (Tache **)malloc(TMAXTRAV*sizeof(Tache *));
if (!tabTache)
{
printf("\033[0;31mErreur: \033[0mmalloc tableau tache\n");
exit(1);
@ -178,7 +179,7 @@ Tache **loadTaches(Offre *tabTravaux[])
for (i=0; i<TMAXTRAV; i++)
{
t=(Tache *)malloc(sizeof(Tache));
if (t==NULL)
if (!t)
{
printf("\033[0;31mErreur: \033[0mmalloc tache\n");
exit(1);

@ -15,6 +15,8 @@ int main()
displayPrecedences(tabP, p_tlog);
loadTaches(tabTravaux);
return 0;
}

@ -91,22 +91,24 @@ ListeDevis insert(ListeDevis l, Devis d)
// Insere en queue de liste (les successeurs)
Liste insertSucc(Liste l, char travaux[])
{
trace("insertSucc");
MaillonSucc *ms;
trace("insertSucc");
MaillonSucc *ms;
ms = (MaillonSucc *)malloc(sizeof(MaillonSucc));
if (ms == NULL)
{
printf("\033[0;31mErreur: \033[0mmalloc liste successeurs\n");
exit(1);
}
ms->nxt=l->nxt;
l->nxt=ms;
strcpy(ms->tache, travaux);
ms = (MaillonSucc *)malloc(sizeof(MaillonSucc));
if (ms == NULL)
{
printf("\033[0;31mErreur: \033[0mmalloc liste successeurs\n");
exit(1);
}
return l;
ms->nxt = l;
l = ms;
strcpy(ms->tache, travaux);
return l;
}
//file
void enfiler(ListeAttente *file, Tache *tache)
{

Loading…
Cancel
Save