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 64 65 66 67 68 69 70 71 72 73 74 75
| int ChargerTableFichier()
{
struct char_fbtAllocator *pAllocCaracs1=NULL, *pAllocCaracs2=NULL, *pAllocCaracs3=NULL, *pAllocCaracs4=NULL;
struct int_fbtAllocator *pAllocLignes1=NULL, *pAllocLignes2=NULL, *pAllocLignes3=NULL, *pAllocLignes4=NULL;
size_t *pTailles1=NULL, *pTailles2=NULL,*pTailles3=NULL,*pTailles4=NULL, nbMots1=0, nbMots2=0,nbMots3=0,nbMots4=0;
int retour = EXIT_FAILURE;
/*Initialisation des allocateurs */
{
size_t nbCaracs1=0,nbCaracs2=0, nbCaracs3=0, nbCaracs4=0;
int nbLignes1=0, nbLignes2=0,nbLignes3=0, nbLignes4=0;
if(CompterToutesTablesFichBinaire1fr(&pTailles1, &nbCaracs1, &nbLignes1)<0)
goto LNettoyage;
if(CompterToutesTablesFichBinaire2fr(&pTailles2, &nbCaracs2, &nbLignes2)<0)
goto LNettoyage;
if(CompterToutesTablesFichBinaire1en(&pTailles3, &nbCaracs3, &nbLignes3)<0)
goto LNettoyage;
if(CompterToutesTablesFichBinaire2en(&pTailles4, &nbCaracs4, &nbLignes4)<0)
goto LNettoyage;
nbMots1 = SommeTailles1fr(pTailles1);
nbMots2 = SommeTailles2fr(pTailles2);
nbMots3 = SommeTailles1en(pTailles3);
nbMots4 = SommeTailles2en(pTailles4);
pAllocCaracs1 = char_CreateFbtAllocator(nbCaracs1);
pAllocCaracs2 = char_CreateFbtAllocator(nbCaracs2);
pAllocCaracs3 = char_CreateFbtAllocator(nbCaracs3);
pAllocCaracs4= char_CreateFbtAllocator(nbCaracs4);
if(pAllocCaracs1==NULL || pAllocCaracs2==NULL|| pAllocCaracs3==NULL|| pAllocCaracs4==NULL)
goto LNettoyage;
pAllocLignes1 = int_CreateFbtAllocator(nbLignes1);
pAllocLignes2 = int_CreateFbtAllocator(nbLignes2);
pAllocLignes3 = int_CreateFbtAllocator(nbLignes3);
pAllocLignes4 = int_CreateFbtAllocator(nbLignes4);
if(pAllocLignes1==NULL || pAllocLignes2==NULL|| pAllocLignes3==NULL|| pAllocLignes4==NULL)
goto LNettoyage;
}
{
MotCompact * pMots1fr = LireToutesTablesFichBinaire1fr(pTailles1, pAllocCaracs1, pAllocLignes1);
MotCompact * pMots2fr = LireToutesTablesFichBinaire2fr(pTailles2, pAllocCaracs2, pAllocLignes2);
MotCompact * pMots1en = LireToutesTablesFichBinaire1en(pTailles3, pAllocCaracs3, pAllocLignes3);
MotCompact * pMots2en = LireToutesTablesFichBinaire2en(pTailles4, pAllocCaracs4, pAllocLignes4);
if(pMots1fr==NULL || pMots2fr==NULL||pMots1en==NULL || pMots2en==NULL)
{
DetruireTableauMotsCompacts(pMots1fr), pMots1fr=NULL;
DetruireTableauMotsCompacts(pMots2fr), pMots2fr=NULL;
DetruireTableauMotsCompacts(pMots1en), pMots1en=NULL;
DetruireTableauMotsCompacts(pMots2en), pMots2en=NULL;
goto LNettoyage;
}
{
calculerlesRegles( pMots1en,pMots1fr,nbMots1);
}
DetruireTableauMotsCompacts(pMots1fr), pMots1fr=NULL;
DetruireTableauMotsCompacts(pMots2fr), pMots2fr=NULL;
DetruireTableauMotsCompacts(pMots1en), pMots1en=NULL;
DetruireTableauMotsCompacts(pMots2en), pMots2en=NULL;
retour = EXIT_SUCCESS;
}
LNettoyage:
free(pTailles1), pTailles1=NULL;
free(pTailles2), pTailles2=NULL;
free(pTailles3), pTailles3=NULL;
free(pTailles4), pTailles4=NULL;
char_DestroyFbtAllocator(pAllocCaracs1), pAllocCaracs1=NULL;
char_DestroyFbtAllocator(pAllocCaracs2), pAllocCaracs2=NULL;
char_DestroyFbtAllocator(pAllocCaracs3), pAllocCaracs3=NULL;
char_DestroyFbtAllocator(pAllocCaracs4), pAllocCaracs4=NULL;
int_DestroyFbtAllocator(pAllocLignes1), pAllocLignes1=NULL;
int_DestroyFbtAllocator(pAllocLignes2), pAllocLignes2=NULL;
int_DestroyFbtAllocator(pAllocLignes3), pAllocLignes3=NULL;
int_DestroyFbtAllocator(pAllocLignes4), pAllocLignes4=NULL;
return retour;
} |
Partager