IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C Discussion :

xmlDocPtr plante mon appli


Sujet :

C

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    101
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 101
    Points : 56
    Points
    56
    Par défaut xmlDocPtr plante mon appli
    bonsoir

    je ne comprend pas pourquoi xmlDocPtr a un endroit donner de mon code plante mon appli et pas ailleurs
    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
     
    if(VOK =="ok")
    {
    blabla
    xmlDocPtr doc;
    blabla
    xmlFreeDoc(doc);
    }
    else
    {
    blabla
    xmlDocPtr log;
    blabla
    xmlFreeDoc(log);
    }
    si executer mon appli avec "ok" à VOK mon appli plante, sinon ne plante pas

    merci d'avance pour votre aide

  2. #2
    Expert éminent sénior
    Avatar de diogene
    Homme Profil pro
    Enseignant Chercheur
    Inscrit en
    Juin 2005
    Messages
    5 761
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Enseignant Chercheur
    Secteur : Enseignement

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 761
    Points : 13 926
    Points
    13 926
    Par défaut
    Si tu utilises doc ou log dans le "blabla", évidemment qu'on ne peut rien dire sur ce qui se passe !

    Sinon, ça plante dans les deux cas probablement puisque tu appelles la fonction xmlFreeDoc() avec un pointeur non initialisé. Que tu t'en aperçoives immédiatement dans un cas et pas dans l'autre est purement un hasard.
    Publication : Concepts en C

    Mon avatar : Glenn Gould

    --------------------------------------------------------------------------
    Une réponse vous a été utile ? Remerciez son auteur en cliquant le pouce vert !

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    101
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 101
    Points : 56
    Points
    56
    Par défaut
    Citation Envoyé par diogene Voir le message

    Sinon, ça plante dans les deux cas probablement puisque tu appelles la fonction xmlFreeDoc() avec un pointeur non initialisé. Que tu t'en aperçoives immédiatement dans un cas et pas dans l'autre est purement un hasard.
    tu peut definir "non initialisé" ?

    merci et bonne fête

  4. #4
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    101
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 101
    Points : 56
    Points
    56
    Par défaut
    voici plus de détaille sur le code mise en cause, je n'ai toujours pas trouver la source du probleme

    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
    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
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
     
    	/* verifier la presence d'un fichier Log */
    	/* le nom du fichier rechercher est egal au nom de dossier avec extension .log */
    	gchar *NDT;
    	NDT = g_path_get_basename(V_Entry1);// extraire le nom du dossier sur le chemin selectionner
    	char *V_slach; V_slach = "/";
    	char *V_log; V_log =".log";
    	const gchar *FChemin;
    	FChemin = g_strconcat(V_Entry1, V_slach, NDT, V_log, NULL);//concatener chemin+nom fichier
    	FILE *fp = NULL;
    	fp = fopen(FChemin,"rb");
    	if (fp == NULL)
    	{
    		/* le fichier log n'existe pas */ 
    			/* création du fichier log */
    			FILE *CFLog = NULL; // Creation_Fichier_Log
    			CFLog = fopen(FChemin,"w");
    			fprintf(CFLog,"<?xml version='1.0' encoding='UTF-8'?>\n");	
    			char *V_TagD; V_TagD = "<";
    			char *V_TagF; V_TagF = ">";
    			char *V_TagRacine = "racinetxt";
    			char *V_TagT;
    			V_TagT = g_strconcat(V_TagD, V_TagRacine, V_TagF, NULL);
    			fprintf(CFLog,"\t");		fprintf(CFLog,V_TagT);			fprintf(CFLog,"\n");
    			V_TagT = g_strconcat(V_TagD, V_slach, V_TagRacine, V_TagF, NULL);
    			fprintf(CFLog,"\t");		fprintf(CFLog,V_TagT);			fprintf(CFLog,"\n");
    			fclose(CFLog);
    			xmlDocPtr doc;
    			xmlNodePtr racine, New_Noeud;
    			doc = xmlParseFile(FChemin);
    			racine = xmlDocGetRootElement(doc);
    			/* Parametre - Chemin_Dossier_a_Traiter = V_Entry1 */
    			New_Noeud =	xmlNewNode(NULL,"Parametre");
    			xmlSetProp(New_Noeud,"Chemin_Dossier_a_Traiter",V_Entry1);
    			/* Parametre - Numeration_Page = V_ComboBox2 */
    			xmlSetProp(New_Noeud,"Numeration_Page",V_ComboBox2);
    			char VVBox2[2];
    			sprintf(VVBox2,"%d",CBox2); //converti un "int" en "char" 
    			xmlSetProp(New_Noeud,"N_Numeration_Page",VVBox2);
    			xmlAddChild(racine,New_Noeud);
    			DIR * dirdossier;
    			dirdossier = opendir(V_Entry1);
    			if (dirdossier != NULL)
    			{
    				int ComptFichier = 0;
    				struct dirent *nomfichier;
    				while ((nomfichier = readdir(dirdossier)) != NULL)
    				{
    					char *extens;
    					char *reffext = "txt";
    					extens = strstr(nomfichier->d_name, "txt");
    					if (extens != NULL)
    					{
    						if (strcmp(extens, reffext) == 0)
    						{
    							/* Nom_Fichiers */
    							New_Noeud =	xmlNewNode(NULL,"Fichier");
    							xmlSetProp(New_Noeud,"Nom_Fichier",nomfichier->d_name);
    							xmlAddChild(racine,New_Noeud);
    							ComptFichier++;
    						}
    					}
    				}//sortie while
    				/* CountFichier - Nombre_de_Fichier_a_Traiter = X */
    				New_Noeud =	xmlNewNode(NULL,"CountFichier");
    				char *V_CountFichier;
    				sprintf(V_CountFichier,"%d",ComptFichier); //converti un "int" en "char" 
    				xmlSetProp(New_Noeud,"Nombre_de_Fichier_a_Traiter",V_CountFichier);
    				xmlAddChild(racine,New_Noeud);
    			}
    			closedir(dirdossier);
    			xmlSaveFile(FChemin,doc);
    			xmlFreeDoc(doc);
    			VBuff = "- Fichier Log Crée \n";
    			gtk_text_buffer_get_start_iter(text_buffer,&IterStart);
    			gtk_text_buffer_insert(text_buffer,&IterStart,VBuff,-1);
     
    	/* Creation du Dossier Post Traitement */
    			FChemin = g_strconcat(V_Entry1, V_slach, "BINAIRE", NULL);//concatener chemin+binaire
    			if(-1 == mkdir(FChemin,S_IRWXU))
    			{
    				VBuff = "- Création du repertoire BINAIRE échoué \n";
    				gtk_text_buffer_get_start_iter(text_buffer,&IterStart);
    				gtk_text_buffer_insert(text_buffer,&IterStart,VBuff,-1);
    			}
    			else
    			{
    				VBuff = "- Répertoire BINAIRE Crée \n";
    				gtk_text_buffer_get_start_iter(text_buffer,&IterStart);
    				gtk_text_buffer_insert(text_buffer,&IterStart,VBuff,-1);
    			}
    	}
    	else
    	{
    		fclose(fp);
    		/* extraire une donnée du fichier Log   */
    		xmlDocPtr mog;
    		xmlNodePtr racinemog;
    		xmlXPathContextPtr contextmog;
    		xmlXPathObjectPtr objmog;
    		mog = xmlParseFile(FChemin);
    		racinemog = xmlDocGetRootElement(mog);
    		contextmog = xmlXPathNewContext(mog);
    		int i;
    			objmog = xmlXPathEvalExpression("/racinetxt/Parametre[@type='Chemin_Dossier_a_Traiter']/text()",contextmog);
    			for(i=0;i<objmog->nodesetval->nodeNr;i++)
    			{
    				xmlNodePtr n = objmog->nodesetval->nodeTab[i];
    				V_Entry1 = n->content;
    			}
    		xmlXPathFreeObject (objmog);
    		xmlXPathFreeContext (contextmog);
    		xmlFreeDoc(mog);
    	}
    merci d'avance pour vos suggestions permettant de corriger ou ameliore mes connaissance du langage C

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    101
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2007
    Messages : 101
    Points : 56
    Points
    56
    Par défaut
    toujours le meme probleme, je n'ai pas trouver encore de solution

  6. #6
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 519
    Points
    41 519
    Par défaut
    Attention au == sur les chaînes de caractères...
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

Discussions similaires

  1. Conversion float/string plante mon appli
    Par chido dans le forum Android
    Réponses: 1
    Dernier message: 23/01/2015, 01h16
  2. [WD17] ReadDirectoryChangesW qui plante mon appli
    Par chapeau_melon dans le forum WinDev
    Réponses: 1
    Dernier message: 09/11/2012, 18h01
  3. pourquoi ma boucle fait planté mon appli ?
    Par zerros dans le forum Windows Forms
    Réponses: 5
    Dernier message: 02/05/2009, 16h21
  4. CArray RemoveAll plante mon appli
    Par damdam78 dans le forum MFC
    Réponses: 5
    Dernier message: 10/09/2008, 11h46
  5. delete[] plante mon appli !
    Par Dauphin dans le forum C++Builder
    Réponses: 8
    Dernier message: 10/12/2005, 20h52

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo