예제 #1
0
파일: 3.c 프로젝트: SimonColin/IN301
void liberer(Liste l)
{
	if(l != NULL)
	{
		liberer(l->nxt);
		free(l);
	}
}
예제 #2
0
void			pf_completely_free_list(t_list *l, void (*liberer)())
{
  t_list		*tmp;

  while (l && l->next)
    {
      tmp = l;
      l = l->next;
      liberer(tmp->data);
      free(tmp);
    }
  if (l)
    {
      liberer(l->data);
      free(l);
    }
}
예제 #3
0
main()
{ 
  int **t ;
  int n,m ;
  printf("Nb de lignes ? "); scanf("%d", &n);
  printf("Nb de colonnes ? "); scanf("%d", &m);
	
  t = lire_mat(n,m);  
    	
  affich_mat(t, n,m) ;

  liberer(t,n,m);  
  //  affich_mat(t, n,m) ;
  return 0;
}
예제 #4
0
파일: list.c 프로젝트: godstefou/projet_c
int main(int argc, char* argv[]){  
    Point p1;
    p1.x = 1; p1.y = 2;  
    Point p2;
    p2.x = 3; p2.y = 4; 
    
    List list = initList(sizeof(Point));
    insertFirst(list, &p1);
    insertFirst(list, &p2);  
    
    Point* test[2];
    test[0] = (Point*) removeFirst(list);
    test[1] = (Point*) removeFirst(list);
     
    /*
    printf("p2.x: %d, p2.y: %d\n", test[0]->x, test[0]->y);
    printf("p1.x: %d, p1.y: %d\n", test[1]->x, test[1]->y);
    */
    liberer(list);
    
    return !(test[0]->x==3 && test[0]->y==4 && test[1]->x==1 && test[1]->y==2);
}
예제 #5
0
파일: decodage.c 프로젝트: malek0512/PLS
int main(int argc, char *argv[]){
    if (argc != 2){
        printf("Donner un fichier en argument\n");
        exit(1);
    } else {

        FILE* file = OuvrirFichier(argv[1]);
        *(argv[1]+strlen(argv[1])-4)='\0';
        FILE* fileCompressed = CreerFichier(strcat(argv[1],"decomp"));
        maillon *Tete, *Queue, *resultatTete=NULL;
        int choix;

        readFromFileBytesInOrder(&Tete,&Queue,file);
        fclose(file);

        if(Tete == NULL){
            printf("ATTENTION ! Le fichier est vide\n");
            exit(1);
        }

        printf("Veuillez faire un choix de compression : \n 1 - RLE \n 2 - MTF \n 3 - Huffman \n 4 - Combinaison des 3 modes de compression \n");
        if(scanf("%d", &choix)==0)
			return -1;
		
        switch(choix){
            case 1: 
                printf("\n**********************************************************");
                printf("\n*               DECODAGE RLE ...                         *");
                printf("\n**********************************************************\n");

				Tete = predecodeRle(Tete);
                decoderRle(Tete);
                writeListeBytes(Tete,fileCompressed);

                printf("\n**********************************************************");
                printf("\n*               DECODAGE RLE FIN                         *");
                printf("\n**********************************************************\n");
                break;
            case 2: 
                printf("\n**********************************************************");
                printf("\n*               DECODAGE MTF ...                         *");
                printf("\n**********************************************************\n");

                resultatTete = MTF2(Tete); 
                writeListeBytes(resultatTete,fileCompressed);
                liberer(resultatTete);

                printf("\n**********************************************************");
                printf("\n*               DECODAGE MTF FIN                         *");
                printf("\n**********************************************************\n");
                
                break;
            case 3:{  
                printf("\n**********************************************************");
                printf("\n*               DECODAGE HUFFMAN ...                     *");
                printf("\n**********************************************************\n");
                resultatTete = decodageHuffmanFinal(&Tete, &Queue); 
				
				#ifdef DEBUGG
                printf("\nVoici le message décodé en Hexa\n");
				print2(resultatTete);
				#endif
                
                //Ecriture du message dans le fichier
                writeListeBytes(resultatTete,fileCompressed);
                liberer(resultatTete);

                printf("\n**********************************************************");
                printf("\n*               DECODAGE HUFFMAN FIN                     *");
                printf("\n**********************************************************\n");
                break;
                   }
            case 4:{  
                printf("\n**********************************************************");
                printf("\n*               DECODAGE  COCKTAIL ...                   *");
                printf("\n**********************************************************\n");
				printf("Veuillez faire un choix des prétraitements à opérer :\n");
				printf("RLE?\n");
				int RLE,mtf;
				if(scanf("%d", &RLE)==0)
					return -1;
				printf("MTF?\n");
				if(scanf("%d", &mtf)==0)
					return -1;

                printf("\n**********************************************************");
                printf("\n*               DECODAGE HUFFMAN ...                     *");
                printf("\n**********************************************************\n");

                resultatTete = decodageHuffmanFinal(&Tete, &Queue); 
                liberer(Tete);
                Tete = resultatTete;

                printf("\n**********************************************************");
                printf("\n*               DECODAGE HUFFMAN FIN                     *");
                printf("\n**********************************************************\n");

                
                if (mtf){ 
                printf("\n**********************************************************");
                printf("\n*               DECODAGE MTF ...                         *");
                printf("\n**********************************************************\n");
                
                resultatTete = MTF2(Tete);
                liberer(Tete);
                Tete = resultatTete;
                
                printf("\n**********************************************************");
                printf("\n*               DECODAGE MTF FIN                         *");
                printf("\n**********************************************************\n");
                }

                if (RLE){ 
                printf("\n**********************************************************");
                printf("\n*               DECODAGE RLE ...                         *");
                printf("\n**********************************************************\n");
                
				Tete = predecodeRle(Tete);
                decoderRle(Tete); 

                printf("\n**********************************************************");
                printf("\n*               DECODAGE RLE FIN                         *");
                printf("\n**********************************************************\n");
                }

#ifdef DEBUGG
                printf("\nVoici le message décodé en Hexa\n");
                print2(Tete);
#endif
                
                //Ecriture du message dans le fichier
                writeListeBytes(Tete,fileCompressed);

                printf("\n**********************************************************");
                printf("\n*               DECODAGE COCKTAIL FIN                    *");
                printf("\n**********************************************************\n");
                break;
                   }
            default: printf("Erreur de choix");
        }
	
                //liberer(Tete);
                fclose(fileCompressed);
    }
    return 0;
}