- Rename ND_DataStruct_Alloc() & ND_DataStruct_Free() into ND_Alloc() & ND_Free(),

- Use ND_Alloc() & ND_Free() into ndbench.
This commit is contained in:
Arnaud G. GIBERT 2024-05-04 12:10:31 +02:00
parent afbf19b5a3
commit 2417b2829e
3 changed files with 57 additions and 50 deletions

View File

@ -680,8 +680,6 @@ typedef int NDT_Recursive_Offset;
# define ND_DataStruct_Traverse_V ND_DataStruct_Traverse_VI
# define ND_DataStruct_Traverse ND_DataStruct_Traverse_I
# define ND_DataStruct_Info_Print ND_DataStruct_Info_Print_I
# define ND_DataStruct_Alloc ND_DataStruct_Alloc_I
# define ND_DataStruct_Free ND_DataStruct_Free_I
# define ND_DataStruct_Value_Add ND_DataStruct_Value_Add_I
# define ND_DataStruct_Value_Remove ND_DataStruct_Value_Remove_I
# define ND_DataStruct_Value_Print ND_DataStruct_Value_Print_I
@ -714,6 +712,8 @@ typedef int NDT_Recursive_Offset;
# define ND_Manager_Exec_V ND_Manager_Exec_VI
# define ND_Manager_Exec ND_Manager_Exec_I
# define ND_Alloc ND_Alloc_I
# define ND_Free ND_Free_I
# define ND_Allocator_Exec ND_Allocator_Exec_I
# define ND_Deallocator_Exec ND_Deallocator_Exec_I
@ -736,8 +736,6 @@ typedef int NDT_Recursive_Offset;
# define ND_DataStruct_Traverse_V ND_DataStruct_Traverse_VC
# define ND_DataStruct_Traverse ND_DataStruct_Traverse_C
# define ND_DataStruct_Info_Print ND_DataStruct_Info_Print_C
# define ND_DataStruct_Alloc ND_DataStruct_Alloc_C
# define ND_DataStruct_Free ND_DataStruct_Free_C
# define ND_DataStruct_Value_Add ND_DataStruct_Value_Add_C
# define ND_DataStruct_Value_Remove ND_DataStruct_Value_Remove_C
# define ND_DataStruct_Value_Print ND_DataStruct_Value_Print_C
@ -770,6 +768,8 @@ typedef int NDT_Recursive_Offset;
# define ND_Manager_Exec_V ND_Manager_Exec_VC
# define ND_Manager_Exec ND_Manager_Exec_C
# define ND_Alloc ND_Alloc_C
# define ND_Free ND_Free_C
# define ND_Allocator_Exec ND_Allocator_Exec_C
# define ND_Deallocator_Exec ND_Deallocator_Exec_C
@ -940,33 +940,6 @@ NDD_DLL_API NDT_Status ND_DataStruct_Info_Print_C( FILE *, NDT_Root *, NDT_Re
/*----------------------------------------------------------------------------*/
/* Alloc memory unsing data structure allocator - Manager function */
/*----------------------------------------------------------------------------*/
/* (O) Memory_Ptr_Ptr: Memory pointer address */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Size: Allocation size */
/* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Alloc_I( void **, NDT_Root *, size_t, void *);
NDD_DLL_API NDT_Status ND_DataStruct_Alloc_C( void **, NDT_Root *, size_t, void *);
/*----------------------------------------------------------------------------*/
/* Free memory unsing data structure allocator - Manager function */
/*----------------------------------------------------------------------------*/
/* (I) Memory_Ptr: Memory pointer */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_DataStruct_Free_I( void *, NDT_Root *, void *);
NDD_DLL_API NDT_Status ND_DataStruct_Free_C( void *, NDT_Root *, void *);
/*----------------------------------------------------------------------------*/
/* Add a new value to a data structure */
/*----------------------------------------------------------------------------*/
@ -1326,6 +1299,33 @@ NDD_DLL_API NDT_Status ND_Manager_Exec_C( NDT_Root *, NDT_Index_Id, NDT_Node
/*----------------------------------------------------------------------------*/
/* Alloc memory unsing data structure allocator - Manager function */
/*----------------------------------------------------------------------------*/
/* (O) Memory_Ptr_Ptr: Memory pointer address */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Size: Allocation size */
/* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Alloc_I( void **, NDT_Root *, size_t, void *);
NDD_DLL_API NDT_Status ND_Alloc_C( void **, NDT_Root *, size_t, void *);
/*----------------------------------------------------------------------------*/
/* Free memory unsing data structure allocator - Manager function */
/*----------------------------------------------------------------------------*/
/* (I) Memory_Ptr: Memory pointer */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Free_I( void *, NDT_Root *, void *);
NDD_DLL_API NDT_Status ND_Free_C( void *, NDT_Root *, void *);
/*----------------------------------------------------------------------------*/
/* Execute an allocator function */
/*----------------------------------------------------------------------------*/

View File

@ -2211,7 +2211,7 @@ NDT_Status ND_DataStruct_Info_Print_C( FILE *Out, NDT_Root *Root_Ptr, NDT_Rec
/* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_DataStruct_Alloc_I( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, void *Data_Ptr)
NDT_Status ND_Alloc_I( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, void *Data_Ptr)
{
return( ND_Allocator_Exec_I( Ptr_Ptr, Root_Ptr, Size, Root_Ptr->Allocator_Name, Root_Ptr->Allocator_Ptr, Data_Ptr));
}
@ -2229,7 +2229,7 @@ NDT_Status ND_DataStruct_Alloc_I( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t
/* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_DataStruct_Alloc_C( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, void *Data_Ptr)
NDT_Status ND_Alloc_C( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, void *Data_Ptr)
{
return( ND_Allocator_Exec_I( Ptr_Ptr, Root_Ptr, Size, Root_Ptr->Allocator_Name, Root_Ptr->Allocator_Ptr, Data_Ptr));
}
@ -2246,7 +2246,7 @@ NDT_Status ND_DataStruct_Alloc_C( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t
/* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_DataStruct_Free_I( void *Ptr, NDT_Root *Root_Ptr, void *Data_Ptr)
NDT_Status ND_Free_I( void *Ptr, NDT_Root *Root_Ptr, void *Data_Ptr)
{
return( ND_Deallocator_Exec_I( Ptr, Root_Ptr, Root_Ptr->Deallocator_Name, Root_Ptr->Deallocator_Ptr, Data_Ptr));
}
@ -2265,7 +2265,7 @@ NDT_Status ND_DataStruct_Free_I( void *Ptr, NDT_Root *Root_Ptr, void *Data_P
/* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_DataStruct_Free_C( void *Ptr, NDT_Root *Root_Ptr, void *Data_Ptr)
NDT_Status ND_Free_C( void *Ptr, NDT_Root *Root_Ptr, void *Data_Ptr)
{
return( ND_Deallocator_Exec_I( Ptr, Root_Ptr, Root_Ptr->Deallocator_Name, Root_Ptr->Deallocator_Ptr, Data_Ptr));
}

View File

@ -174,10 +174,13 @@ cpt t_exec;
/* Définition des valeurs attachées aux noeuds de la structure */
# define NAME_LEN 64
# define NAME_SIZE ( NAME_LEN + 1)
typedef struct
{
int Id;
char *Nom;
char Name[ NAME_SIZE];
} T_Module;
@ -332,7 +335,7 @@ 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( Name, user_args, char *);
ND_VA_ARG_GET( Id, user_args, int);
ND_VA_LIST_CLOSE( user_args);
@ -340,18 +343,18 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
Command_Name = "NDD_CMD_VALUE_ALLOC";
if( ( *Module_Ptr_Ptr = (T_Module *)malloc( sizeof(T_Module))) != NULL)
{
(*Module_Ptr_Ptr)->Nom = strdup(Nom);
(*Module_Ptr_Ptr)->Id = Id;
return( NDS_OK);
}
else
if( ( ND_Alloc( (void **)Module_Ptr_Ptr, Root_Ptr, sizeof(T_Module), NULL)) != NDS_OK)
{
return( NDS_KO);
}
else
{
strncpy( ( *Module_Ptr_Ptr)->Name, Name, NAME_LEN);
( *Module_Ptr_Ptr)->Name[ NAME_LEN] = '\0';
( *Module_Ptr_Ptr)->Id = Id;
return( NDS_OK);
}
}
case NDD_CMD_VALUE_FREE:
@ -373,10 +376,14 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
Command_Name = "NDD_CMD_VALUE_FREE";
free( Module_Ptr->Nom);
free( Module_Ptr);
return( NDS_OK);
if( ( ND_Free( (void *)Module_Ptr, Root_Ptr, NULL)) != NDS_OK)
{
return( NDS_KO);
}
else
{
return( NDS_OK);
}
}
case NDD_CMD_VALUE_COMP:
@ -508,7 +515,7 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
Command_Name = "NDD_CMD_VALUE_PRINT";
fprintf( Out, "Id=%d\tNom=\"%s\"\n", Module_Ptr->Id, Module_Ptr->Nom);
fprintf( Out, "Id=%d\tName: [%s]\n", Module_Ptr->Id, Module_Ptr->Name);
return( NDS_OK);
}