- Implement DS_DataStruct_Value_Add_I, DS_DataStruct_Flush_I() & DS_Free,

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

View File

@ -180,6 +180,7 @@ typedef struct DST_RootDesc
# define DS_DataStruct_Open DS_DataStruct_Open_I # define DS_DataStruct_Open DS_DataStruct_Open_I
# define DS_DataStruct_Close DS_DataStruct_Close_I # define DS_DataStruct_Close DS_DataStruct_Close_I
# define DS_DataStruct_Flush DS_DataStruct_Flush_I
# define DS_DataStruct_Reorg DS_DataStruct_Reorg_I # define DS_DataStruct_Reorg DS_DataStruct_Reorg_I
# define DS_DataStruct_Traverse DS_DataStruct_Traverse_I # define DS_DataStruct_Traverse DS_DataStruct_Traverse_I
# define DS_DataStruct_Convert DS_DataStruct_Convert_I # define DS_DataStruct_Convert DS_DataStruct_Convert_I
@ -189,6 +190,8 @@ typedef struct DST_RootDesc
# define DS_DataStruct_Check DS_DataStruct_Check_I # define DS_DataStruct_Check DS_DataStruct_Check_I
# define DS_DataStruct_Lock DS_DataStruct_Lock_I # define DS_DataStruct_Lock DS_DataStruct_Lock_I
# define DS_DataStruct_Unlock DS_DataStruct_Unlock_I # define DS_DataStruct_Unlock DS_DataStruct_Unlock_I
# define DS_DataStruct_Value_Add DS_DataStruct_Value_Add_I
# define DS_DataStruct_Value_Remove DS_DataStruct_Value_Remove_I
# define DS_Index_Open DS_Index_Open_I # define DS_Index_Open DS_Index_Open_I
# define DS_Index_Close DS_Index_Close_I # define DS_Index_Close DS_Index_Close_I
@ -204,8 +207,6 @@ typedef struct DST_RootDesc
# define DS_Node_Find DS_Node_Find_I # define DS_Node_Find DS_Node_Find_I
# define DS_Value_Alloc DS_Value_Alloc_I # define DS_Value_Alloc DS_Value_Alloc_I
# define DS_Value_Add DS_Value_Add_I
# define DS_Value_Remove DS_Value_Remove_I
# define DS_Value_Free DS_Value_Free_I # define DS_Value_Free DS_Value_Free_I
# define DS_Alloc DS_Alloc_I # define DS_Alloc DS_Alloc_I
@ -224,6 +225,7 @@ typedef struct DST_RootDesc
# define DS_DataStruct_Open DS_DataStruct_Open_L # define DS_DataStruct_Open DS_DataStruct_Open_L
# define DS_DataStruct_Close DS_DataStruct_Close_L # define DS_DataStruct_Close DS_DataStruct_Close_L
# define DS_DataStruct_Flush DS_DataStruct_Flush_L
# define DS_DataStruct_Reorg DS_DataStruct_Reorg_L # define DS_DataStruct_Reorg DS_DataStruct_Reorg_L
# define DS_DataStruct_Traverse DS_DataStruct_Traverse_L # define DS_DataStruct_Traverse DS_DataStruct_Traverse_L
# define DS_DataStruct_Convert DS_DataStruct_Convert_L # define DS_DataStruct_Convert DS_DataStruct_Convert_L
@ -233,6 +235,8 @@ typedef struct DST_RootDesc
# define DS_DataStruct_Check DS_DataStruct_Check_L # define DS_DataStruct_Check DS_DataStruct_Check_L
# define DS_DataStruct_Lock DS_DataStruct_Lock_L # define DS_DataStruct_Lock DS_DataStruct_Lock_L
# define DS_DataStruct_Unlock DS_DataStruct_Unlock_L # define DS_DataStruct_Unlock DS_DataStruct_Unlock_L
# define DS_DataStruct_Value_Add DS_DataStruct_Value_Add_L
# define DS_DataStruct_Value_Remove DS_DataStruct_Value_Remove_L
# define DS_Index_Open DS_Index_Open_L # define DS_Index_Open DS_Index_Open_L
# define DS_Index_Close DS_Index_Close_L # define DS_Index_Close DS_Index_Close_L
@ -248,8 +252,6 @@ typedef struct DST_RootDesc
# define DS_Node_Find DS_Node_Find_L # define DS_Node_Find DS_Node_Find_L
# define DS_Value_Alloc DS_Value_Alloc_L # define DS_Value_Alloc DS_Value_Alloc_L
# define DS_Value_Add DS_Value_Add_L
# define DS_Value_Remove DS_Value_Remove_L
# define DS_Value_Free DS_Value_Free_L # define DS_Value_Free DS_Value_Free_L
# define DS_Alloc DS_Alloc_L # define DS_Alloc DS_Alloc_L
@ -268,6 +270,7 @@ typedef struct DST_RootDesc
# define DS_DataStruct_Open DS_DataStruct_Open_CL # define DS_DataStruct_Open DS_DataStruct_Open_CL
# define DS_DataStruct_Close DS_DataStruct_Close_CL # define DS_DataStruct_Close DS_DataStruct_Close_CL
# define DS_DataStruct_Flush DS_DataStruct_Flush_CL
# define DS_DataStruct_Reorg DS_DataStruct_Reorg_CL # define DS_DataStruct_Reorg DS_DataStruct_Reorg_CL
# define DS_DataStruct_Traverse DS_DataStruct_Traverse_CL # define DS_DataStruct_Traverse DS_DataStruct_Traverse_CL
# define DS_DataStruct_Convert DS_DataStruct_Convert_CL # define DS_DataStruct_Convert DS_DataStruct_Convert_CL
@ -277,6 +280,8 @@ typedef struct DST_RootDesc
# define DS_DataStruct_Check DS_DataStruct_Check_CL # define DS_DataStruct_Check DS_DataStruct_Check_CL
# define DS_DataStruct_Lock DS_DataStruct_Lock_CL # define DS_DataStruct_Lock DS_DataStruct_Lock_CL
# define DS_DataStruct_Unlock DS_DataStruct_Unlock_CL # define DS_DataStruct_Unlock DS_DataStruct_Unlock_CL
# define DS_DataStruct_Value_Add DS_DataStruct_Value_Add_CL
# define DS_DataStruct_Value_Remove DS_DataStruct_Value_Remove_CL
# define DS_Index_Open DS_Index_Open_CL # define DS_Index_Open DS_Index_Open_CL
# define DS_Index_Close DS_Index_Close_CL # define DS_Index_Close DS_Index_Close_CL
@ -292,8 +297,6 @@ typedef struct DST_RootDesc
# define DS_Node_Find DS_Node_Find_CL # define DS_Node_Find DS_Node_Find_CL
# define DS_Value_Alloc DS_Value_Alloc_CL # define DS_Value_Alloc DS_Value_Alloc_CL
# define DS_Value_Add DS_Value_Add_CL
# define DS_Value_Remove DS_Value_Remove_CL
# define DS_Value_Free DS_Value_Free_CL # define DS_Value_Free DS_Value_Free_CL
# define DS_Alloc DS_Alloc_CL # define DS_Alloc DS_Alloc_CL
@ -415,6 +418,18 @@ DSD_API DST_Status DS_DataStruct_Close_CL( NDT_Root *Root_Ptr, DST_Flags Clo
/*----------------------------------------------------------------------------*/
/* Destroy all data of a data structure */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/*----------------------------------------------------------------------------*/
DSD_API NDT_Status DS_DataStruct_Flush_I( NDT_Root *Root_Ptr);
DSD_API NDT_Status DS_DataStruct_Flush_L( NDT_Root *Root_Ptr);
DSD_API NDT_Status DS_DataStruct_Flush_CL( NDT_Root *Root_Ptr);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Print data structure information */ /* Print data structure information */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -431,6 +446,19 @@ DSD_API DST_Status DS_DataStruct_Info_Print_CL( FILE *Out, NDT_Root *Root_Ptr,
/*----------------------------------------------------------------------------*/
/* Add a new value to a data structure */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Value_Ptr: Value pointer */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_DataStruct_Value_Add_I( NDT_Root *Root_Ptr, void *Value_Ptr);
DSD_API DST_Status DS_DataStruct_Value_Add_L( NDT_Root *Root_Ptr, void *Value_Ptr);
DSD_API DST_Status DS_DataStruct_Value_Add_CL( NDT_Root *Root_Ptr, void *Value_Ptr);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Réorganisation d'une structure de données : */ /* Réorganisation d'une structure de données : */
/* - ordonnancement d'une liste non ordonnée */ /* - ordonnancement d'une liste non ordonnée */
@ -665,19 +693,6 @@ DSD_API DST_Status DS_Value_Alloc_CL( void **Value_Ptr_Ptr, NDT_Root *Root_Pt
/*----------------------------------------------------------------------------*/
/* 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 */
/*----------------------------------------------------------------------------*/
DSD_API DST_Status DS_Value_Add_I( NDT_Root *Root_Ptr, void *Value_Ptr);
DSD_API DST_Status DS_Value_Add_L( NDT_Root *Root_Ptr, void *Value_Ptr);
DSD_API DST_Status DS_Value_Add_CL( NDT_Root *Root_Ptr, void *Value_Ptr);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Suppression du premier noeud correspondant à une valeur donnée */ /* Suppression du premier noeud correspondant à une valeur donnée */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -725,11 +740,11 @@ DSD_API DST_Status DS_Alloc_CL( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t S
/* (I) Root : pointeur sur la racine de la structure de données */ /* (I) Root : pointeur sur la racine de la structure de données */
/* (I) Ptr : pointeur sur la zone à désallouer */ /* (I) Ptr : pointeur sur la zone à désallouer */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/*
DSD_API DST_Status DS_Free_I( NDT_Root * Root, void * Ptr); DSD_API DST_Status DS_Free_I( NDT_Root *Root_Ptr, void *Ptr);
DSD_API DST_Status DS_Free_L( NDT_Root * Root, void * Ptr); DSD_API DST_Status DS_Free_L( NDT_Root *Root_Ptr, void *Ptr);
DSD_API DST_Status DS_Free_CL( NDT_Root * Root, void * Ptr); DSD_API DST_Status DS_Free_CL( NDT_Root *Root_Ptr, void *Ptr);
*/
#ifdef __cplusplus #ifdef __cplusplus

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 */ /* 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 */ /* 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 */ /* 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 */ /* (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));
} }

View File

@ -365,7 +365,7 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
Command_Name = "NDD_CMD_VALUE_ALLOC"; Command_Name = "NDD_CMD_VALUE_ALLOC";
LG_LOG_TRACE_0( LGD_LOG_LEVEL_DEFAULT, "CMD_VALUE_ALLOC called..."); LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Command: [%s] called", Command_Name);
if( DS_Alloc( (void **)Module_Ptr_Ptr, Root_Ptr, sizeof( T_Module)) != DSS_OK) if( DS_Alloc( (void **)Module_Ptr_Ptr, Root_Ptr, sizeof( T_Module)) != DSS_OK)
@ -397,15 +397,14 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
ND_VA_LIST_CLOSE( user_args); ND_VA_LIST_CLOSE( user_args);
*/ */
ND_VA_ARG_GET( Value_Ptr, *Args_Ptr, void *); ND_VA_ARG_GET( Module_Ptr_Ptr, *Args_Ptr, T_Module **);
Command_Name = "NDD_CMD_VALUE_FREE"; Command_Name = "NDD_CMD_VALUE_FREE";
/* LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Command: [%s] called", Command_Name);
DS_Free( Root_Ptr, Value_Ptr);
*/ return( DS_Free( Root_Ptr, Module_Ptr_Ptr));
return( NDS_OK);
} }
case NDD_CMD_VALUE_COMP: case NDD_CMD_VALUE_COMP:
@ -878,9 +877,9 @@ void Command_Index_Range_Get( FILE *File_Output, int *Low, int *High, char
void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, char *Arg1, char *Arg2, char *Arg3, FILE *File_Input) void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, char *Arg1, char *Arg2, char *Arg3, FILE *File_Input)
{ {
DST_Status status; DST_Status status;
int sub_choice_int1, sub_choice_int2, low, high, i, j, nb_removed, Nb_Detected, Nb_Corrected; int sub_choice_int1, sub_choice_int2, low, high, i, j, inc, nb_removed, nb_detected, nb_corrected;
char *sub_choice_str; char *sub_choice_str;
T_Module Ref_Module, *Module_Ptr; T_Module ref_module, *module_ptr;
char buf[ BUF_SIZE], local_arg1[ BUF_SIZE], local_arg2[ BUF_SIZE], local_arg3[ BUF_SIZE]; char buf[ BUF_SIZE], local_arg1[ BUF_SIZE], local_arg2[ BUF_SIZE], local_arg3[ BUF_SIZE];
NDT_Index_Type index_subtype; NDT_Index_Type index_subtype;
@ -958,7 +957,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
} }
else else
{ {
LG_LOG_INFO_1( "Data structure: [%s] created", sub_choice_str); LG_LOG_INFO_1( "Data structure: [%s] opened", sub_choice_str);
} }
t_stop( t_exec); t_stop( t_exec);
@ -972,33 +971,44 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
Command_Exec_Begin_Print( File_Output, Choice); Command_Exec_Begin_Print( File_Output, Choice);
t_start( t_exec); t_start( t_exec);
if( ( status = DS_DataStruct_Close( *DS_Ptr_Ptr, DSD_CLOSE) != DSS_OK))
if( ( status = DS_DataStruct_Close( *DS_Ptr_Ptr, DSD_CLOSE)) != DSS_OK)
{ {
LG_LOG_ERROR_1( "Can't close data structure: (%d)", status); LG_LOG_ERROR_1( "Can't close data structure, status: (%d)", status);
} }
else else
{ {
LG_LOG_INFO_0( "Data structure closed"); LG_LOG_INFO_0( "Data structure closed");
*DS_Ptr_Ptr = NULL; *DS_Ptr_Ptr = NULL;
} }
t_stop( t_exec);
Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
break;
}
case DS_FLUSH:
{
Command_Exec_Begin_Print( File_Output, Choice);
t_start( t_exec);
if( ( status = DS_DataStruct_Flush( *DS_Ptr_Ptr)) != DSS_OK)
{
LG_LOG_ERROR_1( "Can't flush data structure, status: (%d)", status);
}
else
{
LG_LOG_INFO_0( "Data structure flushed");
}
t_stop( t_exec); t_stop( t_exec);
Command_Exec_End_Print( File_Output, Choice, t_exec, 1); Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
break; break;
} }
/* /*
case DS_FLUSH:
{
Command_Exec_Begin_Print( File_Output, Choice);
t_start( t_exec);
ND_DataStruct_Flush( *DS_Ptr_Ptr);
t_stop( t_exec);
Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
break;
}
case DS_CHECK: case DS_CHECK:
{ {
Command_Exec_Begin_Print( File_Output, Choice); Command_Exec_Begin_Print( File_Output, Choice);
@ -1038,25 +1048,22 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
Command_Exec_End_Print( File_Output, Choice, t_exec, 1); Command_Exec_End_Print( File_Output, Choice, t_exec, 1);
break; break;
} }
/*
case DS_VALUE_ADD: case DS_VALUE_ADD:
{ {
int order; int order;
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Value"); Command_Index_Range_Get( File_Output, &low, &high, Arg1, Arg2, File_Input, Choice, "Value");
if( low != -1) if( low != -1)
{ {
if( Arg2 == NULL) if( Arg3 == NULL)
{ {
fprintf( File_Output, "DS_Value_Add: Add order ( 0:croissant | 1:decroissant) ? "); DBD_ARG_READ( Arg3, local_arg3, "DS_Value_Add: Add order ( 0:croissant | 1:decroissant): ");
fgets( buf, BUF_LEN ,stdin);
Arg2 = buf;
} }
order = atoi( Arg2); order = atoi( Arg3);
// fprintf( File_Output, "DS_Value_Add: Adding from: (%d) to: (%d) order: (%d)...\n", low, high, order); // fprintf( File_Output, "DS_Value_Add: Adding from: (%d) to: (%d) order: (%d)...\n", low, high, order);
// fflush( File_Output); // fflush( File_Output);
@ -1064,50 +1071,35 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
LG_LOG_INFO_3( "DS_Value_Add: Adding from: (%d) to: (%d) order: (%d)...", low, high, order); LG_LOG_INFO_3( "DS_Value_Add: Adding from: (%d) to: (%d) order: (%d)...", low, high, order);
t_start( t_exec);
if( order == 0) if( order == 0)
{ {
i = low; i = low;
j = high + 1; j = high + 1;
inc = 1;
while( i < j)
{
if( ND_Value_Alloc( (void **)&Module_Ptr, *DS_Ptr_Ptr, "x", i) == NDS_OK)
{
ND_DataStruct_Value_Add( *DS_Ptr_Ptr, Module_Ptr);
}
else
{
// fprintf( File_Output, "DS_Value_Add: Allocation Failled !\n");
LG_LOG_ERROR_0( "DS_Value_Add: Allocation Failled !");
break;
}
i++;
}
} }
else else
{ {
i = high; i = high;
j = low - 1; j = low - 1;
inc = -1;
}
while( i > j) t_start( t_exec);
while( i != j)
{ {
if( ND_Value_Alloc( (void **)&Module_Ptr, *DS_Ptr_Ptr, "x", i) == NDS_OK) if( DS_Value_Alloc( (void **)&module_ptr, *DS_Ptr_Ptr, i, "x") == NDS_OK)
{ {
ND_DataStruct_Value_Add( *DS_Ptr_Ptr, Module_Ptr); DS_DataStruct_Value_Add( *DS_Ptr_Ptr, module_ptr);
} }
else else
{ {
// fprintf( File_Output, "DS_Value_Add: Allocation Failled !\n");
LG_LOG_ERROR_0( "DS_Value_Add: Allocation Failled !"); LG_LOG_ERROR_0( "DS_Value_Add: Allocation Failled !");
break; break;
} }
i--; i += inc;
}
} }
t_stop( t_exec); t_stop( t_exec);
@ -1117,7 +1109,7 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
break; break;
} }
/*
case DS_VALUE_REMOVE: case DS_VALUE_REMOVE:
{ {
int order; int order;
@ -1191,15 +1183,19 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
break; break;
} }
*/
case DS_VALUE_PRINT: case DS_VALUE_PRINT:
{ {
Command_Exec_Begin_Print( File_Output, Choice); Command_Exec_Begin_Print( File_Output, Choice);
ND_DataStruct_Value_Print( File_Output, *DS_Ptr_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 99, 0); if( ( status = DS_DataStruct_Value_Print( File_Output, *DS_Ptr_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 99, 0)) != DSS_OK)
break; {
LG_LOG_ERROR_1( "Unable to print data structure values, status: (%d)", status);
} }
break;
}
/*
case DS_VALUE_FIND: case DS_VALUE_FIND:
{ {
Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Search"); Command_Index_Range_Get( File_Output, &low, &high, Arg1, File_Input, Choice, "Search");
@ -1244,7 +1240,12 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
for( i = low; i <= high; i++) for( i = low; i <= high; i++)
{ {
DS_Index_Open( *DS_Ptr_Ptr, (NDT_Index_Id)i, DBD_IDX_TYPE_FIFO); if( ( status = DS_Index_Open( *DS_Ptr_Ptr, (NDT_Index_Id)i, DBD_IDX_TYPE_FIFO)) != DSS_OK)
{
LG_LOG_ERROR_2( "Unable to open index: (%d), status: (%d)", i, status);
break;
}
} }
t_stop( t_exec); t_stop( t_exec);