- Implement DS_DataStruct_Value_Add_I, DS_DataStruct_Flush_I() & DS_Free,

- dsbench testings...
This commit is contained in:
2024-05-01 13:28:27 +02:00
parent 42ab4c9029
commit 6c74ecb997
3 changed files with 268 additions and 215 deletions

View File

@@ -914,6 +914,35 @@ DST_Status DS_DataStruct_Close_I( NDT_Root *Root_Ptr, DST_Flags Close_Mode)
/*----------------------------------------------------------------------------*/
/* Destroy all data of a data structure */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/*----------------------------------------------------------------------------*/
NDT_Status DS_DataStruct_Flush_I( NDT_Root *Root_Ptr)
{
NDT_Status nd_status;
if( ( nd_status = ND_DataStruct_Flush_I( Root_Ptr)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to flush datastructure, status: (%d)", nd_status);
return( DSS_KO);
}
else
{
return( DSS_OK);
}
}
/*----------------------------------------------------------------------------*/
/* Print data structure information */
/*----------------------------------------------------------------------------*/
@@ -1276,6 +1305,126 @@ DST_Status DS_DataStruct_Check_I ( NDT_Root * Root, int * Nb_Detected, int * Nb_
/*----------------------------------------------------------------------------*/
/* Add a new value to a data structure */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Value_Ptr: Value pointer */
/*----------------------------------------------------------------------------*/
DST_Status DS_DataStruct_Value_Add_I( NDT_Root *Root_Ptr, void *Value_Ptr)
{
DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)( Root_Ptr->User_Ptr);
DST_Status status;
NDT_Status nd_status;
/* On vérifie que la data structure est valide */
/*
if( RootDesc_Ptr->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
/* On vérifie la structure */
/*
Nb_Detected = Nb_Corrected = 0;
rc = DS_DataStruct_Check_L (Root, &Nb_Detected, &Nb_Corrected, DS_stderr);
if (rc != DSS_OK)
{
sprintf (DS_Error_Msg, "Error DS_Value_Add : unable to check the data structure");
DS_Error_Print ();
return rc;
}
}
*/
/* On rend la structure invalide le temps de l'ajout */
RootDesc_Ptr->Valid = FALSE;
/* Ajout de la valeur */
if( ( nd_status = ND_DataStruct_Value_Add( Root_Ptr, Value_Ptr)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to add a value to the data structure: (%d)", nd_status);
// if (!DS_ERROR(rc)) RootDesc->Valid = TRUE;
return( DSS_KO);
}
/* On rend la structure à nouveau valide */
RootDesc_Ptr->Valid = TRUE;
return( DSS_OK);
}
/*----------------------------------------------------------------------------*/
/* Suppression du premier noeud correspondant à une valeur donnée */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de données */
/* (I) Reference_Value : pointeur sur la valeur de référence */
/* (I) Removed_Value : adresse d'un pointeur sur la valeur supprimée */
/*----------------------------------------------------------------------------*/
/*
DST_Status DS_Value_Remove_I ( NDT_Root * Root, void * Reference_Value, void ** Removed_Value )
{
DST_Status rc;
DST_RootDesc * RootDesc = (DST_RootDesc *)(Root->User);
/* On vérifie que la data structure est valide */
/*
if (RootDesc->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
/* On vérifie la structure */
/*
Nb_Detected = Nb_Corrected = 0;
rc = DS_DataStruct_Check_L (Root, &Nb_Detected, &Nb_Corrected, DS_stderr);
if (rc != DSS_OK)
{
sprintf (DS_Error_Msg, "Error DS_Value_Remove : unable to check the data structure");
DS_Error_Print ();
return rc;
}
}
/* On rend la structure invalide le temps de la suppression de valeur */
/*
RootDesc->Valid = FALSE;
/* Suppression du noeud correspondant à la valeur de référence */
/*
rc = ND_Value_Remove (Root, Reference_Value, Removed_Value);
if (rc != NDS_OK)
{
sprintf (DS_Error_Msg, "Error DS_Value_Remove : unable to remove a value from the data structure");
DS_Error_Print ();
if (!DS_ERROR(rc)) RootDesc->Valid = TRUE;
return rc;
}
/* On rend la structure à nouveau valide */
/*
RootDesc->Valid = TRUE;
return DSS_OK;
}
/*----------------------------------------------------------------------------*/
/* Print all the data structure values */
/*----------------------------------------------------------------------------*/
@@ -1777,118 +1926,6 @@ DST_Status DS_Value_Alloc_I( void **Value_Ptr_Ptr, NDT_Root *Root_Ptr, ... )
/*----------------------------------------------------------------------------*/
/* Ajout d'une valeur à une structure de données */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de données */
/* (I) Value : pointeur sur la valeur à ajouter à la structure de données */
/*----------------------------------------------------------------------------*/
DST_Status DS_Value_Add_I( NDT_Root *Root_Ptr, void *Value_Ptr)
{
DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)( Root_Ptr->User_Ptr);
DST_Status status;
NDT_Status nd_status;
/* On vérifie que la data structure est valide */
/*
if( RootDesc_Ptr->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
/* On vérifie la structure */
/*
Nb_Detected = Nb_Corrected = 0;
rc = DS_DataStruct_Check_L (Root, &Nb_Detected, &Nb_Corrected, DS_stderr);
if (rc != DSS_OK)
{
sprintf (DS_Error_Msg, "Error DS_Value_Add : unable to check the data structure");
DS_Error_Print ();
return rc;
}
}
*/
/* On rend la structure invalide le temps de l'ajout */
RootDesc_Ptr->Valid = FALSE;
/* Ajout de la valeur */
if( ( nd_status = ND_DataStruct_Value_Add( Root_Ptr, Value_Ptr)) != NDS_OK)
{
LG_LOG_ERROR_1( "Unable to add a value to the data structure: (%d)", nd_status);
// if (!DS_ERROR(rc)) RootDesc->Valid = TRUE;
return( DSS_KO);
}
/* On rend la structure à nouveau valide */
RootDesc_Ptr->Valid = TRUE;
return( DSS_OK);
}
/*----------------------------------------------------------------------------*/
/* Suppression du premier noeud correspondant à une valeur donnée */
/*----------------------------------------------------------------------------*/
/* (I) Root : pointeur sur la racine de la structure de données */
/* (I) Reference_Value : pointeur sur la valeur de référence */
/* (I) Removed_Value : adresse d'un pointeur sur la valeur supprimée */
/*----------------------------------------------------------------------------*/
/*
DST_Status DS_Value_Remove_I ( NDT_Root * Root, void * Reference_Value, void ** Removed_Value )
{
DST_Status rc;
DST_RootDesc * RootDesc = (DST_RootDesc *)(Root->User);
/* On vérifie que la data structure est valide */
/*
if (RootDesc->Valid == FALSE)
{
int Nb_Detected, Nb_Corrected;
/* On vérifie la structure */
/*
Nb_Detected = Nb_Corrected = 0;
rc = DS_DataStruct_Check_L (Root, &Nb_Detected, &Nb_Corrected, DS_stderr);
if (rc != DSS_OK)
{
sprintf (DS_Error_Msg, "Error DS_Value_Remove : unable to check the data structure");
DS_Error_Print ();
return rc;
}
}
/* On rend la structure invalide le temps de la suppression de valeur */
/*
RootDesc->Valid = FALSE;
/* Suppression du noeud correspondant à la valeur de référence */
/*
rc = ND_Value_Remove (Root, Reference_Value, Removed_Value);
if (rc != NDS_OK)
{
sprintf (DS_Error_Msg, "Error DS_Value_Remove : unable to remove a value from the data structure");
DS_Error_Print ();
if (!DS_ERROR(rc)) RootDesc->Valid = TRUE;
return rc;
}
/* On rend la structure à nouveau valide */
/*
RootDesc->Valid = TRUE;
return DSS_OK;
}
/*----------------------------------------------------------------------------*/
/* Désallocation d'une valeur d'une structure de données */
/*----------------------------------------------------------------------------*/
@@ -1929,9 +1966,9 @@ DST_Status DS_Alloc_I( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size)
/* (I) Ptr : pointeur sur la zone à désallouer */
/*----------------------------------------------------------------------------*/
DST_Status DS_Free_I( NDT_Root *Root, void *Ptr)
DST_Status DS_Free_I( NDT_Root *Root_Ptr, void *Ptr)
{
// return DS_DataStruct_Free (Ptr, Root->User);
return( DS_DataStruct_Free( Ptr, Root_Ptr->User_Ptr));
}