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 :

Problème de suppression


Sujet :

C

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Rédacteur
    Avatar de Franck.H
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2004
    Messages
    6 951
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2004
    Messages : 6 951
    Par défaut Problème de suppression


    Je tourne autour d'un problème depuis un petit moment maintenant donc je fait appel à des yeux neufs

    Suppression d'un noeud de ma liste double :
    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
    DECLSPEC void b_list_remove_node (BList * p_list,
                                      BList * p_node)
    {
       if (p_node)
       {
          if (p_node->p_prev)
             p_node->p_prev->p_next = p_node->p_next;
          if (p_node->p_next)
             p_node->p_next->p_prev = p_node->p_prev;
     
          if (p_node == p_list)
             p_list = p_list->p_next;
     
          p_node->p_prev = NULL;
          p_node->p_next = NULL;
     
    #ifdef BLIB_MEM_TRACE
          b_mem_trace_add_comment (
             p_node, &BLib_mem_info, DELETE_BLIST_NODE);
    #endif // BLIB_MEM_TRACE
     
          b_free (p_node);
       }
    }
    Appel de la fermeture de la liste:
    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
    DECLSPEC void b_list_free (BList * p_list)
    {
       if (p_list)
       {
          BList * p_first = b_list_first (p_list);
     
          while (p_first)
          {
             b_list_remove_node (p_first, p_first);
             p_first = b_list_next (p_first);
          }
     
     #ifdef BLIB_MEM_TRACE
          b_mem_trace_add_comment (
             p_list, &BLib_mem_info, DELETE_BLIST);
    #endif // BLIB_MEM_TRACE
       }
    }
    La sortie de mon traçage :
    ==== Creating new BList at: 0x0 ====
    >> malloc ptr at: 0x8410a0
    --- Adding BList node at: 0x8410a0
    >> malloc ptr at: 0x8410b8
    --- Adding BList node at: 0x8410b8
    >> malloc ptr at: 0x8410d0
    --- Adding BList node at: 0x8410d0
    >> malloc ptr at: 0x8410e8
    --- Adding BList node at: 0x8410e8
    >> malloc ptr at: 0x841100
    --- Adding BList node at: 0x841100
    >> malloc ptr at: 0x841118
    --- Adding BList node at: 0x841118
    >> malloc ptr at: 0x841130
    --- Adding BList node at: 0x841130
    >> malloc ptr at: 0x841148
    --- Adding BList node at: 0x841148
    >> malloc ptr at: 0x841160
    --- Adding BList node at: 0x841160
    --- Deleting BList node at: 0x8410a0
    >> free ptr at: 0x8410a0
    --- Deleting BList node at: 0x841040
    >> free ptr at: 0x841040
    ==== Deleting BList at: 0x841160 ====

    Pour moi tout est bon dans le code donc un oeil neuf me fera le plus grand bien

    Mon Site
    Ma bibliothèque de gestion des chaînes de caractères en C

    L'imagination est plus importante que le savoir. A. Einstein

    Je ne répond à aucune question technique par MP, merci d'avance !

  2. #2
    Rédacteur
    Avatar de Franck.H
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Janvier 2004
    Messages
    6 951
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : France, Haut Rhin (Alsace)

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Service public

    Informations forums :
    Inscription : Janvier 2004
    Messages : 6 951
    Par défaut
    C'est bon problème résolu, j'ai un peu changé mes fonctions:

    Suppression d'un noeud:
    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
    DECLSPEC BList * b_list_remove_node (BList * p_list,
                                      BList * p_node)
    {
       BList * p = p_list;
     
       if (p_node)
       {
          if (p_node->p_prev)
             p_node->p_prev->p_next = p_node->p_next;
          if (p_node->p_next)
             p_node->p_next->p_prev = p_node->p_prev;
     
          if (p_node == p_list)
             p = p_list->p_next;
     
          p_node->p_prev = NULL;
          p_node->p_next = NULL;
     
    #ifdef BLIB_MEM_TRACE
          b_mem_trace_add_comment (
             p_node, &BLib_mem_info, DELETE_BLIST_NODE);
    #endif // BLIB_MEM_TRACE
     
          b_free (p_node);
       }
     
       return p;
    }
    Suppression de la liste:
    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
    DECLSPEC void b_list_free (BList * p_list)
    {
       if (p_list)
       {
          p_list = b_list_first (p_list);
     
          while (p_list)
             p_list = b_list_remove_node (p_list, p_list);
     
     #ifdef BLIB_MEM_TRACE
          b_mem_trace_add_comment (
             p_list, &BLib_mem_info, DELETE_BLIST);
    #endif // BLIB_MEM_TRACE
       }
    }
    Et pour le coup ma sortie est plus juste:
    ==== Creating new BList at: 0x0 ====
    >> malloc ptr at: 0x7110a0
    --- Adding BList node at: 0x7110a0
    >> malloc ptr at: 0x7110b8
    --- Adding BList node at: 0x7110b8
    >> malloc ptr at: 0x7110d0
    --- Adding BList node at: 0x7110d0
    >> malloc ptr at: 0x7110e8
    --- Adding BList node at: 0x7110e8
    >> malloc ptr at: 0x711100
    --- Adding BList node at: 0x711100
    >> malloc ptr at: 0x711118
    --- Adding BList node at: 0x711118
    >> malloc ptr at: 0x711130
    --- Adding BList node at: 0x711130
    >> malloc ptr at: 0x711148
    --- Adding BList node at: 0x711148
    >> malloc ptr at: 0x711160
    --- Adding BList node at: 0x711160
    --- Deleting BList node at: 0x7110a0
    >> free ptr at: 0x7110a0
    --- Deleting BList node at: 0x7110b8
    >> free ptr at: 0x7110b8
    --- Deleting BList node at: 0x7110d0
    >> free ptr at: 0x7110d0
    --- Deleting BList node at: 0x7110e8
    >> free ptr at: 0x7110e8
    --- Deleting BList node at: 0x711100
    >> free ptr at: 0x711100
    --- Deleting BList node at: 0x711118
    >> free ptr at: 0x711118
    --- Deleting BList node at: 0x711130
    >> free ptr at: 0x711130
    --- Deleting BList node at: 0x711148
    >> free ptr at: 0x711148
    --- Deleting BList node at: 0x711160
    >> free ptr at: 0x711160
    ==== Deleting BList at: 0x0 ====
    Mon Site
    Ma bibliothèque de gestion des chaînes de caractères en C

    L'imagination est plus importante que le savoir. A. Einstein

    Je ne répond à aucune question technique par MP, merci d'avance !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème de suppression de ligne dans ma base !
    Par gregman dans le forum ASP
    Réponses: 2
    Dernier message: 21/05/2005, 08h14
  2. Problème de suppression de fichier
    Par sorry60 dans le forum Assembleur
    Réponses: 7
    Dernier message: 23/04/2005, 18h33
  3. [JTable] problème après suppression d'une ligne
    Par fredo3500 dans le forum Composants
    Réponses: 7
    Dernier message: 17/03/2005, 10h01
  4. [Excel - VBA] Problème de suppression de lignes...
    Par beholder2 dans le forum Macros et VBA Excel
    Réponses: 8
    Dernier message: 28/01/2005, 17h27
  5. Réponses: 4
    Dernier message: 16/04/2004, 08h20

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