Add and use ND_Index_Clear() private function.
libnode pass valgrind test!
This commit is contained in:
parent
a512c467f7
commit
2260f97db2
@ -1,9 +1,9 @@
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* $RCSfile: libnode.c,v $ */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* $Revision: 2.6 $ */
|
||||
/* $Revision: 2.7 $ */
|
||||
/* $Name: $ */
|
||||
/* $Date: 2002/04/09 17:08:17 $ */
|
||||
/* $Date: 2002/07/29 14:53:50 $ */
|
||||
/* $Author: agibert $ */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
#include <libnode.h>
|
||||
|
||||
#ifdef _LIBVER
|
||||
VER_INFO_EXPORT (libnode,"$Revision: 2.6 $", "$Name: $",__FILE__,"$Author: agibert $")
|
||||
VER_INFO_EXPORT (libnode,"$Revision: 2.7 $", "$Name: $",__FILE__,"$Author: agibert $")
|
||||
#endif
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ NDT_Status ND_Default_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT
|
||||
|
||||
Command_Name = "NDD_CMD_MANAGER_VERSION";
|
||||
|
||||
*Version_Name_Ptr = "$Revision: 2.6 $ $Name: $ $Date: 2002/04/09 17:08:17 $ $Author: agibert $";
|
||||
*Version_Name_Ptr = "$Revision: 2.7 $ $Name: $ $Date: 2002/07/29 14:53:50 $ $Author: agibert $";
|
||||
|
||||
return( NDS_OK);
|
||||
}
|
||||
@ -491,19 +491,15 @@ NDT_Status ND_Index_Open_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_In
|
||||
return(NDS_ERRAPI);
|
||||
}
|
||||
|
||||
if( ( status = ND_Index_Clear( Root_Ptr, Index_Id)) != NDS_OK)
|
||||
{
|
||||
sprintf( ND_Error_Msg, "Error ND_Index_Open_I: Index cleaning error");
|
||||
ND_Error_Print();
|
||||
return( NDS_KO);
|
||||
}
|
||||
|
||||
Root_Ptr->Index_Tab[Index_Id].Type = Type & NDD_INDEX_STATUS_RMSK | NDD_INDEX_STATUS_OPENED ;
|
||||
|
||||
Root_Ptr->Index_Tab[Index_Id].Head = NULL;
|
||||
Root_Ptr->Index_Tab[Index_Id].Tail = NULL;
|
||||
Root_Ptr->Index_Tab[Index_Id].Save = NULL;
|
||||
|
||||
Root_Ptr->Index_Tab[Index_Id].Max_Dif = DEF_MAX_DIF;
|
||||
|
||||
Root_Ptr->Index_Tab[Index_Id].Node_Number = 0;
|
||||
Root_Ptr->Index_Tab[Index_Id].Max_Depth = 0;
|
||||
Root_Ptr->Index_Tab[Index_Id].Min_Depth = NDD_HUGE_LONG;
|
||||
Root_Ptr->Index_Tab[Index_Id].Nb_Equ = 0;
|
||||
|
||||
Root_Ptr->Index_Open_Count++;
|
||||
|
||||
if( Index_Id != NDD_INDEX_PRIMARY)
|
||||
@ -533,7 +529,7 @@ NDT_Status ND_Index_Open_I( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_In
|
||||
}
|
||||
}
|
||||
|
||||
return(NDS_OK);
|
||||
return( NDS_OK);
|
||||
}
|
||||
|
||||
|
||||
@ -3426,6 +3422,39 @@ NDT_Status ND_Node_Free ( NDT_Root *Root_Ptr, NDT_Node *Node_Ptr)
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Création d'une nouvelle structure de données */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* (O) Root: adresse d'un pointeur sur la racine de la nouvelle structure */
|
||||
/* (I) Type: type de la structure.de données (liste ou arbre binaire) */
|
||||
/* (I) Allocator: pointeur vers la fonction d'allocation */
|
||||
/* (I) Desallocator: pointeur vers la fonction de désallocation */
|
||||
/* (I) Data : pointeur de données utiles à l'allocateur */
|
||||
/* (I) Own_Value : indique si la structure est propriétaire de ses valeurs */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
||||
NDT_Status ND_Index_Clear( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id)
|
||||
{
|
||||
Root_Ptr->Index_Tab[Index_Id].Type = NDD_INDEX_STATUS_UNKNOWN;
|
||||
|
||||
Root_Ptr->Index_Tab[Index_Id].Head = NULL;
|
||||
Root_Ptr->Index_Tab[Index_Id].Tail = NULL;
|
||||
Root_Ptr->Index_Tab[Index_Id].Save = NULL;
|
||||
|
||||
Root_Ptr->Index_Tab[Index_Id].Max_Dif = DEF_MAX_DIF;
|
||||
|
||||
Root_Ptr->Index_Tab[Index_Id].Node_Number = 0;
|
||||
Root_Ptr->Index_Tab[Index_Id].Max_Depth = 0;
|
||||
Root_Ptr->Index_Tab[Index_Id].Min_Depth = NDD_HUGE_LONG;
|
||||
Root_Ptr->Index_Tab[Index_Id].Nb_Equ = 0;
|
||||
|
||||
return( NDS_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Allocation d'une racine de structure de données */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
@ -3465,13 +3494,22 @@ NDT_Status ND_Node_Root_Alloc( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb,
|
||||
|
||||
for( index_id = 0; index_id < Index_Nb; index_id++)
|
||||
{
|
||||
(*Root_Ptr_Ptr)->Index_Tab[index_id].Type = NDD_INDEX_STATUS_CLOSED;
|
||||
|
||||
if( ( Type_Ptr[index_id] & NDD_INDEX_STATUS_MSK) == NDD_INDEX_STATUS_OPENED)
|
||||
{
|
||||
status = ND_Index_Open_I( *Root_Ptr_Ptr, index_id, Type_Ptr[index_id]);
|
||||
if( ND_ERROR( status)) return( status);
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ( status = ND_Index_Clear( *Root_Ptr_Ptr, index_id)) != NDS_OK)
|
||||
{
|
||||
sprintf( ND_Error_Msg, "Error ND_Index_Open_I: Index cleaning error");
|
||||
ND_Error_Print();
|
||||
return( NDS_KO);
|
||||
}
|
||||
|
||||
(*Root_Ptr_Ptr)->Index_Tab[index_id].Type = NDD_INDEX_STATUS_CLOSED;
|
||||
}
|
||||
}
|
||||
|
||||
return(NDS_OK);
|
||||
|
@ -1,9 +1,9 @@
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* $RCSfile: libnode.h,v $ */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
/* $Revision: 2.3 $ */
|
||||
/* $Revision: 2.4 $ */
|
||||
/* $Name: $ */
|
||||
/* $Date: 2002/02/28 21:53:47 $ */
|
||||
/* $Date: 2002/07/29 14:53:51 $ */
|
||||
/* $Author: agibert $ */
|
||||
/*---------------------------------------------------------------------------------*/
|
||||
|
||||
@ -116,6 +116,18 @@ NDT_Status ND_Node_Alloc (NDT_Root * Root, NDT_Node ** New_Node);
|
||||
/*------------------------------------------------------------------------------*/
|
||||
NDT_Status ND_Node_Free (NDT_Root * Root, NDT_Node * Node);
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Création d'une nouvelle structure de données */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* (O) Root: adresse d'un pointeur sur la racine de la nouvelle structure */
|
||||
/* (I) Type: type de la structure.de données (liste ou arbre binaire) */
|
||||
/* (I) Allocator: pointeur vers la fonction d'allocation */
|
||||
/* (I) Desallocator: pointeur vers la fonction de désallocation */
|
||||
/* (I) Data : pointeur de données utiles à l'allocateur */
|
||||
/* (I) Own_Value : indique si la structure est propriétaire de ses valeurs */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
NDT_Status ND_Index_Clear( NDT_Root *, NDT_Index_Id);
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* Création de la racine d'une structure de données quelconque */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
|
Loading…
Reference in New Issue
Block a user