- Implement DS_Value_Alloc_I(), DS_Value_Add(), DS_Alloc_I(), DS_DataStruct_Value_Print(), DS_DataStruct_Lock() & DS_DataStruct_Unlock(),
- Debug with dsbench: ADD_VALUE & SHOW.
This commit is contained in:
parent
6492980a9b
commit
813967de98
@ -183,9 +183,9 @@ typedef struct DST_RootDesc
|
||||
# define DS_DataStruct_Traverse DS_DataStruct_Traverse_I
|
||||
# define DS_DataStruct_Convert DS_DataStruct_Convert_I
|
||||
# define DS_DataStruct_Info_Print DS_DataStruct_Info_Print_I
|
||||
# define DS_DataStruct_Value_Print DS_DataStruct_Value_Print_I
|
||||
# define DS_DataStruct_Print DS_DataStruct_Print_I
|
||||
# define DS_DataStruct_Check DS_DataStruct_Check_I
|
||||
# define DS_DataStruct_Dump DS_DataStruct_Dump_I
|
||||
# define DS_DataStruct_Lock DS_DataStruct_Lock_I
|
||||
# define DS_DataStruct_Unlock DS_DataStruct_Unlock_I
|
||||
# define DS_Node_Root_Get DS_Node_Root_Get_I
|
||||
@ -219,9 +219,9 @@ typedef struct DST_RootDesc
|
||||
# define DS_DataStruct_Traverse DS_DataStruct_Traverse_L
|
||||
# define DS_DataStruct_Convert DS_DataStruct_Convert_L
|
||||
# define DS_DataStruct_Info_Print DS_DataStruct_Info_Print_L
|
||||
# define DS_DataStruct_Value_Print DS_DataStruct_Value_Print_L
|
||||
# define DS_DataStruct_Print DS_DataStruct_Print_L
|
||||
# define DS_DataStruct_Check DS_DataStruct_Check_L
|
||||
# define DS_DataStruct_Dump DS_DataStruct_Dump_L
|
||||
# define DS_DataStruct_Lock DS_DataStruct_Lock_L
|
||||
# define DS_DataStruct_Unlock DS_DataStruct_Unlock_L
|
||||
# define DS_Node_Root_Get DS_Node_Root_Get_L
|
||||
@ -255,9 +255,9 @@ typedef struct DST_RootDesc
|
||||
# define DS_DataStruct_Traverse DS_DataStruct_Traverse_CL
|
||||
# define DS_DataStruct_Convert DS_DataStruct_Convert_CL
|
||||
# define DS_DataStruct_Info_Print DS_DataStruct_Info_Print_CL
|
||||
# define DS_DataStruct_Value_Print DS_DataStruct_Value_Print_CL
|
||||
# define DS_DataStruct_Print DS_DataStruct_Print_CL
|
||||
# define DS_DataStruct_Check DS_DataStruct_Check_CL
|
||||
# define DS_DataStruct_Dump DS_DataStruct_Dump_CL
|
||||
# define DS_DataStruct_Lock DS_DataStruct_Lock_CL
|
||||
# define DS_DataStruct_Unlock DS_DataStruct_Unlock_CL
|
||||
# define DS_Node_Root_Get DS_Node_Root_Get_CL
|
||||
@ -359,10 +359,10 @@ DSD_API DST_Status DS_DataStruct_Open_CL( const char *DS_Name, NDT_Root **Roo
|
||||
/* (I) Lock_Mode : type de verrou à poser sur la structure */
|
||||
/* (O) Locked : verrou effectif (TRUE ou FALSE) */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/*
|
||||
DSD_API DST_Status DS_DataStruct_Lock_I( NDT_Root * Root, DST_Flags Lock_Mode, int * Locked);
|
||||
DSD_API DST_Status DS_DataStruct_Lock_L( NDT_Root * Root, DST_Flags Lock_Mode, int * Locked);
|
||||
DSD_API DST_Status DS_DataStruct_Lock_CL( NDT_Root * Root, DST_Flags Lock_Mode, int * Locked);
|
||||
|
||||
DSD_API DST_Status DS_DataStruct_Lock_I( NDT_Root *Root_Ptr, DST_Flags Lock_Mode, int *Locked);
|
||||
DSD_API DST_Status DS_DataStruct_Lock_L( NDT_Root *Root_Ptr, DST_Flags Lock_Mode, int *Locked);
|
||||
DSD_API DST_Status DS_DataStruct_Lock_CL( NDT_Root *Root_Ptr, DST_Flags Lock_Mode, int *Locked);
|
||||
|
||||
|
||||
|
||||
@ -371,10 +371,10 @@ DSD_API DST_Status DS_DataStruct_Lock_CL( NDT_Root * Root, DST_Flags Lock_Mode,
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* (I) Root : pointeur sur la racine de la structure */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/*
|
||||
DSD_API DST_Status DS_DataStruct_Unlock_I( NDT_Root * Root);
|
||||
DSD_API DST_Status DS_DataStruct_Unlock_L( NDT_Root * Root);
|
||||
DSD_API DST_Status DS_DataStruct_Unlock_CL( NDT_Root * Root);
|
||||
|
||||
DSD_API DST_Status DS_DataStruct_Unlock_I( NDT_Root *Root_Ptr);
|
||||
DSD_API DST_Status DS_DataStruct_Unlock_L( NDT_Root *Root_Ptr);
|
||||
DSD_API DST_Status DS_DataStruct_Unlock_CL( NDT_Root *Root_Ptr);
|
||||
|
||||
|
||||
|
||||
@ -475,15 +475,19 @@ DSD_API DST_Status DS_DataStruct_Check_CL( NDT_Root * Root, int * Nb_Detected,
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Affichage de la structure de données */
|
||||
/* Print all the data structure values */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* (I) Root : pointeur sur la racine de la structure */
|
||||
/* (I) Out : flux de sortie */
|
||||
/* (I) Stream: Output stream */
|
||||
/* (I) Root_Ptr: Data structure pointer */
|
||||
/* (I) Recursive_Mode: Child or Parent */
|
||||
/* (I) Recursive_Depth: Curent recursion depth */
|
||||
/* (I) Recursive_Offset: Curent print out offset */
|
||||
/* (I) ...: User args */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/*
|
||||
DSD_API DST_Status DS_DataStruct_Dump_I( NDT_Root * Root, FILE * Out);
|
||||
DSD_API DST_Status DS_DataStruct_Dump_L( NDT_Root * Root, FILE * Out);
|
||||
DSD_API DST_Status DS_DataStruct_Dump_CL( NDT_Root * Root, FILE * Out);
|
||||
|
||||
DSD_API DST_Status DS_DataStruct_Value_Print_I( FILE *Out_Ptr, NDT_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...);
|
||||
DSD_API DST_Status DS_DataStruct_Value_Print_L( FILE *Out_Ptr, NDT_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...);
|
||||
DSD_API DST_Status DS_DataStruct_Value_Print_CL( FILE *Out_Ptr, NDT_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...);
|
||||
|
||||
|
||||
|
||||
@ -582,14 +586,14 @@ DSD_API DST_Status DS_Node_Find_CL( NDT_Root * Root, NDT_Node ** Node, void * V
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Allocation d'une valeur d'une structure de données */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* (I) Root : pointeur sur la racine de la structure de données */
|
||||
/* (O) Value : adresse d'un pointeur sur la valeur à allouer */
|
||||
/* (I) Root : pointeur sur la racine de la structure de données */
|
||||
/* (I) ... : arguments relatifs à l'allocation de la valeur */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/*
|
||||
DSD_API DST_Status DS_Value_Alloc_I( NDT_Root * Root, void ** Value, ...);
|
||||
DSD_API DST_Status DS_Value_Alloc_L( NDT_Root * Root, void ** Value, ...);
|
||||
DSD_API DST_Status DS_Value_Alloc_CL( NDT_Root * Root, void ** Value, ...);
|
||||
|
||||
DSD_API DST_Status DS_Value_Alloc_I( void **Value_Ptr_Ptr, NDT_Root *Root_Ptr, ...);
|
||||
DSD_API DST_Status DS_Value_Alloc_L( void **Value_Ptr_Ptr, NDT_Root *Root_Ptr, ...);
|
||||
DSD_API DST_Status DS_Value_Alloc_CL( void **Value_Ptr_Ptr, NDT_Root *Root_Ptr, ...);
|
||||
|
||||
|
||||
|
||||
@ -599,10 +603,10 @@ DSD_API DST_Status DS_Value_Alloc_CL( NDT_Root * Root, void ** Value, ...);
|
||||
/* (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, void * Value);
|
||||
DSD_API DST_Status DS_Value_Add_L( NDT_Root * Root, void * Value);
|
||||
DSD_API DST_Status DS_Value_Add_CL( NDT_Root * Root, void * Value);
|
||||
|
||||
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);
|
||||
|
||||
|
||||
|
||||
@ -636,14 +640,14 @@ DSD_API DST_Status DS_Value_Free_CL( NDT_Root * Root, void * Value);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Allocation de mémoire pour une structure de données : */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* (O) Ptr : adresse du pointeur sur la zone de données allouée */
|
||||
/* (I) Root : pointeur sur la racine de la structure de données */
|
||||
/* (I) Size : taille mémoire à allouer */
|
||||
/* (O) Ptr : adresse du pointeur sur la zone de données allouée */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/*
|
||||
DSD_API DST_Status DS_Alloc_I( NDT_Root * Root, size_t Size, void ** Ptr);
|
||||
DSD_API DST_Status DS_Alloc_L( NDT_Root * Root, size_t Size, void ** Ptr);
|
||||
DSD_API DST_Status DS_Alloc_CL( NDT_Root * Root, size_t Size, void ** Ptr);
|
||||
|
||||
DSD_API DST_Status DS_Alloc_I( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size);
|
||||
DSD_API DST_Status DS_Alloc_L( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size);
|
||||
DSD_API DST_Status DS_Alloc_CL( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size);
|
||||
|
||||
|
||||
|
||||
|
220
lib/libdatastr.c
220
lib/libdatastr.c
@ -683,61 +683,76 @@ Strange: why end the heap here ?
|
||||
/* (I) Lock_Mode : type de verrou à poser sur la structure */
|
||||
/* (O) Locked : verrou effectif (TRUE ou FALSE) */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/*
|
||||
DST_Status DS_DataStruct_Lock_I ( NDT_Root * Root, DST_Flags Lock_Mode, int * Locked )
|
||||
|
||||
DST_Status DS_DataStruct_Lock_I( NDT_Root *Root_Ptr, DST_Flags Lock_Mode, int *Locked )
|
||||
{
|
||||
DST_Status rc;
|
||||
SMT_Heap * Heap;
|
||||
char * Heap_Name = ((DST_RootDesc *)(Root->User))->Heap_Name;
|
||||
char *Heap_Name = ( (DST_RootDesc *)( Root_Ptr->User_Ptr))->Heap_Name;
|
||||
|
||||
SMT_Status sm_status;
|
||||
SMT_Heap *heap_ptr;
|
||||
|
||||
|
||||
/* Réouverture du heap sous-jacent (rafraîchissement des segments) + verrouillage */
|
||||
/*
|
||||
rc = SM_Heap_Open (Heap_Name, &Heap, 0, SMD_OPEN | Lock_Mode, Locked);
|
||||
if (rc != SMS_OK)
|
||||
|
||||
if( ( sm_status = SM_Heap_Open( Heap_Name, &heap_ptr, 0, ( SMD_OPEN | Lock_Mode), Locked)) != SMS_OK)
|
||||
{
|
||||
sprintf (DS_Error_Msg, "Error DS_DataStruct_Lock : unable to reopen the data structure heap \"%s\" for %s",
|
||||
Heap_Name, DSD_MSK_READ (Lock_Mode) ? "reading" : "writing");
|
||||
DS_Error_Print ();
|
||||
LG_LOG_ERROR_3( "Unable to reopen the data structure heap: [%s] for [%s], status: (%d)",
|
||||
Heap_Name, (DSD_MSK_READ( Lock_Mode) ? "reading" : "writing"), sm_status);
|
||||
|
||||
return rc;
|
||||
return( DSS_KO);
|
||||
}
|
||||
|
||||
return DSS_OK;
|
||||
return( DSS_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Déverrouillage d'une structure de données */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* (I) Root : pointeur sur la racine de la structure */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/*
|
||||
DST_Status DS_DataStruct_Unlock_I ( NDT_Root * Root )
|
||||
{
|
||||
DST_Status rc;
|
||||
SMT_Heap * Heap;
|
||||
char * Heap_Name = ((DST_RootDesc *)(Root->User))->Heap_Name;
|
||||
|
||||
rc = SM_Heap_IsOpen (Heap_Name, &Heap);
|
||||
if (rc != SMS_YES)
|
||||
DST_Status DS_DataStruct_Unlock_I( NDT_Root *Root_Ptr)
|
||||
{
|
||||
sprintf (DS_Error_Msg, "Error DS_DataStruct_Unlock : the data structure heap \"%s\" is not open", Heap_Name);
|
||||
DS_Error_Print ();
|
||||
char *Heap_Name = ( (DST_RootDesc *)( Root_Ptr->User_Ptr))->Heap_Name;
|
||||
|
||||
return rc;
|
||||
SMT_Status sm_status;
|
||||
SMT_Heap *heap_ptr;
|
||||
|
||||
|
||||
if( ( sm_status = SM_Heap_IsOpen( Heap_Name, &heap_ptr)) != SMS_OK)
|
||||
{
|
||||
LG_LOG_ERROR_2( "Unable to check if heap: [%s] is open, status: (%d)", Heap_Name, sm_status);
|
||||
|
||||
return( DSS_KO);
|
||||
}
|
||||
else
|
||||
{
|
||||
if( heap_ptr == NULL)
|
||||
{
|
||||
LG_LOG_ERROR_1( "Data structure heap: [%s] is not open", Heap_Name);
|
||||
|
||||
return( DSS_KO);
|
||||
}
|
||||
}
|
||||
|
||||
rc = SM_Heap_Unlock (Heap);
|
||||
if (rc != SMS_OK)
|
||||
if( ( sm_status = SM_Heap_Unlock( heap_ptr)) != SMS_OK)
|
||||
{
|
||||
sprintf (DS_Error_Msg, "Error DS_DataStruct_Unlock : unable to unlock the data structure heap \"%s\"", Heap_Name);
|
||||
DS_Error_Print ();
|
||||
LG_LOG_ERROR_2( "Unable to unlock the data structure heap: [%s], status: (%d)", Heap_Name, sm_status);
|
||||
|
||||
return rc;
|
||||
return( DSS_KO);
|
||||
}
|
||||
|
||||
return DSS_OK;
|
||||
return( DSS_OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Fermeture d'une structure de données */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
@ -791,6 +806,7 @@ DST_Status DS_DataStruct_Close_I( NDT_Root *Root_Ptr, DST_Flags Close_Mode)
|
||||
return( DSS_KO);
|
||||
}
|
||||
|
||||
|
||||
/* Suppression du sémaphore */
|
||||
|
||||
semctl( RootDesc_Ptr->OpenSemId, 0, IPC_RMID, sem_ctl);
|
||||
@ -824,11 +840,9 @@ DST_Status DS_DataStruct_Close_I( NDT_Root *Root_Ptr, DST_Flags Close_Mode)
|
||||
if( ( status = DS_DataStruct_Free( RootDesc_Ptr, (void *)RootDesc_Ptr)) != DSS_OK)
|
||||
{
|
||||
LG_LOG_ERROR_2( "Unable to free data structure: [%s], status: (%d)", ds_name, status);
|
||||
|
||||
return( status);
|
||||
}
|
||||
|
||||
return( DSS_OK);
|
||||
return( status);
|
||||
}
|
||||
}
|
||||
else /* Fermeture simple de la data structure */
|
||||
@ -1237,17 +1251,31 @@ DST_Status DS_DataStruct_Check_I ( NDT_Root * Root, int * Nb_Detected, int * Nb_
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Affiche la structure de données */
|
||||
/* Print all the data structure values */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* (I) Root : pointeur sur la racine de la structure */
|
||||
/* (I) Out : flux de sortie */
|
||||
/* (I) Stream: Output stream */
|
||||
/* (I) Root_Ptr: Data structure pointer */
|
||||
/* (I) Recursive_Mode: Child or Parent */
|
||||
/* (I) Recursive_Depth: Curent recursion depth */
|
||||
/* (I) Recursive_Offset: Curent print out offset */
|
||||
/* (I) ...: User args */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/*
|
||||
DST_Status DS_DataStruct_Dump_I ( NDT_Root * Root, FILE * Out )
|
||||
|
||||
DST_Status DS_DataStruct_Value_Print_I( FILE *Out_Ptr, NDT_Root *Root_Ptr, NDT_Recursive_Mode Recursive_Mode, NDT_Recursive_Depth Recursive_Depth, NDT_Recursive_Offset Recursive_Offset, ...)
|
||||
{
|
||||
DST_Status rc;
|
||||
DST_RootDesc * RootDesc = (DST_RootDesc *)(Root->User);
|
||||
DST_RootDesc *RootDesc_Ptr = (DST_RootDesc *)( Root_Ptr->User_Ptr);
|
||||
|
||||
DST_Status status;
|
||||
NDT_Status nd_status;
|
||||
va_list user_args;
|
||||
|
||||
|
||||
va_start( user_args, Recursive_Offset);
|
||||
|
||||
/* On vérifie que la data structure est valide */
|
||||
/*
|
||||
@ -1267,21 +1295,30 @@ DST_Status DS_DataStruct_Dump_I ( NDT_Root * Root, FILE * Out )
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/* Affichage de la node structure */
|
||||
/*
|
||||
rc = ND_DataStruct_Dump (Root, Out);
|
||||
if (rc != NDS_OK)
|
||||
|
||||
if( ( nd_status = ND_DataStruct_Value_Print_VI( Out_Ptr, Root_Ptr, Recursive_Mode, Recursive_Depth, Recursive_Offset, &user_args)) != NDS_OK)
|
||||
{
|
||||
sprintf (DS_Error_Msg, "Error DS_DataStruct_Dump : unable to dump the node structure");
|
||||
DS_Error_Print ();
|
||||
LG_LOG_ERROR_1( "Unable to dump the node structure: (%d)", nd_status);
|
||||
|
||||
return rc;
|
||||
status = DSS_KO;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = DSS_OK;
|
||||
}
|
||||
|
||||
return DSS_OK;
|
||||
va_end( user_args);
|
||||
|
||||
return( status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Récupération du premier noeud d'une structure */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
@ -1589,31 +1626,49 @@ DST_Status DS_Node_Find_I ( NDT_Root * Root, NDT_Node ** Node, void * Value, voi
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Allocation d'une valeur d'une structure de données */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* (I) Root : pointeur sur la racine de la structure de données */
|
||||
/* (O) Value : adresse d'un pointeur sur la valeur à allouer */
|
||||
/* (I) Root : pointeur sur la racine de la structure de données */
|
||||
/* (I) ... : arguments relatifs à l'allocation de la valeur */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/*
|
||||
DST_Status DS_Value_Alloc_I ( NDT_Root * Root, void ** Value, ... )
|
||||
|
||||
DST_Status DS_Value_Alloc_I( void **Value_Ptr_Ptr, NDT_Root *Root_Ptr, ... )
|
||||
{
|
||||
DST_Status rc;
|
||||
va_list Args;
|
||||
DST_Status status;
|
||||
NDT_Status nd_status;
|
||||
va_list user_args;
|
||||
|
||||
|
||||
/* Récupération des arguments pour l'allocation de la valeur */
|
||||
/*
|
||||
va_start (Args, Value);
|
||||
|
||||
va_start( user_args, Root_Ptr);
|
||||
|
||||
|
||||
/* Appel du manager */
|
||||
/*
|
||||
rc = ND_Manager_Exec (Root->Manager, NDD_CMD_MAKE_VALUE, Root, Value, Args);
|
||||
|
||||
va_end (Args);
|
||||
if( ( nd_status = ND_Manager_Exec( Root_Ptr, NDD_INDEX_UNKNOWN, NULL, NDD_CMD_VALUE_ALLOC, Value_Ptr_Ptr, &user_args)) != NDS_OK)
|
||||
{
|
||||
LG_LOG_ERROR_1( "Unnable to alloc a new value: (%d)", nd_status);
|
||||
|
||||
return rc;
|
||||
status = DSS_KO;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = DSS_OK;
|
||||
}
|
||||
|
||||
va_end( user_args);
|
||||
|
||||
return( status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Ajout d'une valeur à une structure de données */
|
||||
@ -1621,15 +1676,18 @@ DST_Status DS_Value_Alloc_I ( NDT_Root * Root, void ** Value, ... )
|
||||
/* (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, void * Value )
|
||||
|
||||
DST_Status DS_Value_Add_I( NDT_Root *Root_Ptr, void *Value_Ptr)
|
||||
{
|
||||
DST_Status rc;
|
||||
DST_RootDesc * RootDesc = (DST_RootDesc *)(Root->User);
|
||||
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->Valid == FALSE)
|
||||
if( RootDesc_Ptr->Valid == FALSE)
|
||||
{
|
||||
int Nb_Detected, Nb_Corrected;
|
||||
|
||||
@ -1645,29 +1703,27 @@ DST_Status DS_Value_Add_I ( NDT_Root * Root, void * Value )
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
/* On rend la structure invalide le temps de l'ajout */
|
||||
/*
|
||||
RootDesc->Valid = FALSE;
|
||||
|
||||
RootDesc_Ptr->Valid = FALSE;
|
||||
|
||||
/* Ajout de la valeur */
|
||||
/*
|
||||
rc = ND_Value_Add (Root, Value);
|
||||
if (rc != NDS_OK)
|
||||
|
||||
if( ( nd_status = ND_DataStruct_Value_Add( Root_Ptr, Value_Ptr)) != NDS_OK)
|
||||
{
|
||||
sprintf (DS_Error_Msg, "Error DS_Value_Add : unable to add a value to the data structure");
|
||||
DS_Error_Print ();
|
||||
LG_LOG_ERROR_1( "Unable to add a value to the data structure: (%d)", nd_status);
|
||||
|
||||
if (!DS_ERROR(rc)) RootDesc->Valid = TRUE;
|
||||
// if (!DS_ERROR(rc)) RootDesc->Valid = TRUE;
|
||||
|
||||
return rc;
|
||||
return( DSS_KO);
|
||||
}
|
||||
|
||||
/* On rend la structure à nouveau valide */
|
||||
/*
|
||||
RootDesc->Valid = TRUE;
|
||||
|
||||
return DSS_OK;
|
||||
RootDesc_Ptr->Valid = TRUE;
|
||||
|
||||
return( DSS_OK);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
@ -1738,21 +1794,27 @@ DST_Status DS_Value_Free_I ( NDT_Root * Root, void * Value )
|
||||
return ND_Value_Free (Root, Value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Allocation de mémoire pour une structure de données : */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* (O) Ptr : adresse du pointeur sur la zone de données allouée */
|
||||
/* (I) Root : pointeur sur la racine de la structure de données */
|
||||
/* (I) Size : taille mémoire à allouer */
|
||||
/* (O) Ptr : adresse du pointeur sur la zone de données allouée */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
DST_Status DS_Alloc_I( NDT_Root *Root, size_t Size, void **Ptr)
|
||||
DST_Status DS_Alloc_I( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size)
|
||||
{
|
||||
// return DS_DataStruct_Alloc (Size, Ptr, Root->User);
|
||||
return( DS_DataStruct_Alloc( Ptr_Ptr, Size, Root_Ptr->User_Ptr));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Désallocation d'une ressource pour une structure de données : */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
@ -126,7 +126,7 @@ DST_Status DS_Semaphore_Operate (int, struct sembuf *, unsigned int);
|
||||
/* Fonction d'allocation attachée à une structure de données : */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
DST_Status DS_DataStruct_Alloc ( void **Ptr, size_t Size, void *Data );
|
||||
DST_Status DS_DataStruct_Alloc ( void **Ptr_Ptr, size_t Size, void *Data );
|
||||
|
||||
|
||||
|
||||
|
@ -96,11 +96,14 @@ typedef struct {
|
||||
|
||||
T_Cpt t_exec;
|
||||
|
||||
|
||||
|
||||
/* Définition des valeurs attachées aux noeuds de la structure */
|
||||
|
||||
typedef struct {
|
||||
typedef struct
|
||||
{
|
||||
int Id;
|
||||
char * Nom;
|
||||
char Nom[ DSD_NAME_SIZE];
|
||||
} T_Module;
|
||||
|
||||
|
||||
@ -189,8 +192,8 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
|
||||
|
||||
ND_VA_LIST_OPEN( user_args, *Args_Ptr);
|
||||
|
||||
ND_VA_ARG_GET( Nom, user_args, char *);
|
||||
ND_VA_ARG_GET( Id, user_args, int);
|
||||
ND_VA_ARG_GET( Nom, user_args, char *);
|
||||
|
||||
ND_VA_LIST_CLOSE( user_args);
|
||||
|
||||
@ -199,22 +202,21 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
|
||||
|
||||
LG_LOG_TRACE_0( LGD_LOG_LEVEL_DEFAULT, "CMD_VALUE_ALLOC called...");
|
||||
|
||||
/*
|
||||
if( DS_Alloc( Root, sizeof( T_Module) + strlen( Nom) + 1, (void **)Module) == DSS_OK)
|
||||
{
|
||||
(* Module_Ptr_Ptr)->Id = Id;
|
||||
(* Module_Ptr_Ptr)->Nom = (char *)((size_t)(*Module) + sizeof (T_Module));
|
||||
strcpy( ( *Module)->Nom, Nom);
|
||||
|
||||
return( DSS_OK)
|
||||
}
|
||||
else
|
||||
if( DS_Alloc( (void **)Module_Ptr_Ptr, Root_Ptr, sizeof( T_Module)) != DSS_OK)
|
||||
{
|
||||
LG_LOG_ERROR_0( "Allocation error");
|
||||
|
||||
return( DSS_KO)
|
||||
return( DSS_KO);
|
||||
}
|
||||
else
|
||||
{
|
||||
( *Module_Ptr_Ptr)->Id = Id;
|
||||
strncpy( ( *Module_Ptr_Ptr)->Nom, Nom, DSD_NAME_LEN);
|
||||
( *Module_Ptr_Ptr)->Nom[ DSD_NAME_LEN] = '\0';
|
||||
|
||||
return( DSS_OK);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
case NDD_CMD_VALUE_FREE:
|
||||
@ -369,9 +371,10 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
|
||||
|
||||
T_Module *Module_Ptr = (T_Module *)Node_Ptr->Value;
|
||||
|
||||
|
||||
Command_Name = "NDD_CMD_VALUE_PRINT";
|
||||
|
||||
fprintf( Out, "Id Module: (%d) Nom Module: [%s]", Module_Ptr->Id, Module_Ptr->Nom);
|
||||
LG_LOG_INFO_2( "Id Module: (%d) Nom Module: [%s]", Module_Ptr->Id, Module_Ptr->Nom);
|
||||
|
||||
return( NDS_OK);
|
||||
}
|
||||
@ -585,7 +588,7 @@ int main( int argc, char **argv)
|
||||
NDT_Index_Type index_type = ( NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO);
|
||||
char *tmp;
|
||||
int n, m, i, j;
|
||||
int choice, Nb_Removed, Locked;
|
||||
int choice, nb_removed, locked;
|
||||
int Nb_Detected, Nb_Corrected;
|
||||
T_Module *Module, Ref_Module;
|
||||
NDT_Node *Node;
|
||||
@ -624,6 +627,7 @@ int main( int argc, char **argv)
|
||||
{
|
||||
fprintf( stdout, "\nNom de la structure à créer ? ");
|
||||
fgets( DataStruct_Name, 100, stdin);
|
||||
|
||||
if( strlen( DataStruct_Name) < 2)
|
||||
{
|
||||
fprintf( stdout, "Bad name!\n");
|
||||
@ -664,6 +668,7 @@ int main( int argc, char **argv)
|
||||
{
|
||||
fprintf (stdout, "\nNom de la structure à ouvrir ? ");
|
||||
fgets( DataStruct_Name, 100, stdin);
|
||||
|
||||
if( strlen( DataStruct_Name) < 2)
|
||||
{
|
||||
fprintf( stdout, "Bad name!\n");
|
||||
@ -742,19 +747,20 @@ int main( int argc, char **argv)
|
||||
m - n + 1, t_exec.sec, (m - n + 1) / t_exec.sec);
|
||||
break;
|
||||
}
|
||||
|
||||
*/
|
||||
case ADD_VALUE:
|
||||
{
|
||||
fprintf (stdout, "\nPlage des valeurs à ajouter (?->?) : ");
|
||||
gets (buf);
|
||||
tmp = strstr (buf, "->");
|
||||
fprintf (stdout, "\nPlage des valeurs à ajouter (?-?) : ");
|
||||
fgets( buf, 100, stdin);
|
||||
tmp = strstr( buf, "-");
|
||||
|
||||
if( tmp != NULL)
|
||||
{
|
||||
*tmp = '\0';
|
||||
n = atoi( buf);
|
||||
tmp++;
|
||||
tmp++;
|
||||
m = atoi( tmp);
|
||||
|
||||
if( m < n)
|
||||
{
|
||||
printf ("\nEntrées non valides\n");
|
||||
@ -767,21 +773,24 @@ int main( int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
|
||||
DS_DataStruct_Lock (Root, DSD_WRITE, &Locked);
|
||||
DS_DataStruct_Lock( Root_Ptr, DSD_WRITE, &locked);
|
||||
|
||||
fprintf (stdout, "\nOrdre d'ajout (croissant=0 décroissant=1) ? ");
|
||||
gets (buf);
|
||||
fgets( buf, 100, stdin);
|
||||
choice = atoi (buf);
|
||||
|
||||
if( choice == 0)
|
||||
{
|
||||
i = n;
|
||||
j = m + 1;
|
||||
t_start (t_exec);
|
||||
|
||||
while( i < j)
|
||||
{
|
||||
if (DS_Value_Alloc (Root, (void **)&Module, "x", i) == NDS_OK) DS_Value_Add (Root, Module);
|
||||
if( DS_Value_Alloc( (void **)&Module, Root_Ptr, i, "x") == NDS_OK) DS_Value_Add( Root_Ptr, Module);
|
||||
i++;
|
||||
}
|
||||
|
||||
t_stop( t_exec);
|
||||
}
|
||||
else
|
||||
@ -789,21 +798,23 @@ int main( int argc, char **argv)
|
||||
i = m;
|
||||
j = n - 1;
|
||||
t_start( t_exec);
|
||||
|
||||
while( i > j)
|
||||
{
|
||||
if (DS_Value_Alloc (Root, (void **)&Module, "x", i) == NDS_OK) DS_Value_Add (Root, Module);
|
||||
if( DS_Value_Alloc( (void **)&Module, Root_Ptr, i, "x") == NDS_OK) DS_Value_Add( Root_Ptr, Module);
|
||||
i--;
|
||||
}
|
||||
|
||||
t_stop (t_exec);
|
||||
}
|
||||
|
||||
DS_DataStruct_Unlock (Root);
|
||||
DS_DataStruct_Unlock( Root_Ptr);
|
||||
|
||||
fprintf( stdout, "\n%d valeur(s) ajoutée(s) en %.4f sec (%.2f ajouts/sec)\n", m - n + 1, \
|
||||
t_exec.sec, (m - n + 1) / t_exec.sec);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
case REMOVE_VALUE:
|
||||
{
|
||||
Nb_Removed = 0;
|
||||
@ -942,15 +953,15 @@ int main( int argc, char **argv)
|
||||
// DS_DataStruct_Unlock (Root);
|
||||
break;
|
||||
}
|
||||
/*
|
||||
|
||||
case SHOW:
|
||||
{
|
||||
DS_DataStruct_Lock (Root, DSD_READ, &Locked);
|
||||
DS_DataStruct_Dump (Root, stdout);
|
||||
DS_DataStruct_Unlock (Root);
|
||||
DS_DataStruct_Lock( Root_Ptr, DSD_READ, &locked);
|
||||
DS_DataStruct_Value_Print( stdout, Root_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0);
|
||||
DS_DataStruct_Unlock( Root_Ptr);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
case CHECK:
|
||||
{
|
||||
Nb_Corrected = Nb_Detected = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user