- Add DataStruct Handlers,
- Update Open_DataStruct() API.
This commit is contained in:
parent
9708977753
commit
2d259e4f2f
@ -1,8 +1,11 @@
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
LibNode V 3.0.0-1 - A. GIBERT - 2024/05/xx
|
||||
------------------------------------------------------------------------------------------------------------------------------------
|
||||
All:
|
||||
|
||||
- All:
|
||||
- Working on new API...
|
||||
- Add DataStruct Handlers,
|
||||
- Update Open_DataStruct() API.
|
||||
|
||||
|
||||
|
||||
|
@ -625,7 +625,7 @@ void Demo( char *Demo_File_Name, short Optimized_Mode)
|
||||
index_type_ptr = index_type_final_tab;
|
||||
}
|
||||
|
||||
if( ( status = ND_DataStruct_Open( &demo_ds_ptr, INDEX_NB, index_type_ptr, "Demo_DS_Manager", Demo_DS_Manager, NULL, NULL, NULL, NULL,0, NULL)) != NDS_OK)
|
||||
if( ( status = ND_DataStruct_Open( &demo_ds_ptr, "NDDemo0", INDEX_NB, index_type_ptr, "Demo_DS_Manager", Demo_DS_Manager, NULL, 0, NULL)) != NDS_OK)
|
||||
{
|
||||
printf( "ND_DataStruct_Open() failed (%d) !\n", status);
|
||||
}
|
||||
|
141
include/node.h
141
include/node.h
@ -54,9 +54,16 @@
|
||||
# define NDD_TRUE 1
|
||||
# define NDD_FALSE 0
|
||||
|
||||
|
||||
|
||||
/* Helper Macro */
|
||||
|
||||
# define NDD_MIN(A,B) ( ( A > B) ? B : A)
|
||||
# define NDD_MAX(A,B) ( ( A < B) ? B : A)
|
||||
|
||||
# define ND_STRCPY( dest, src, size) strncpy( (dest), (src), (size)); \
|
||||
(dest)[ (size) - 1] = '\0'
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@ -143,6 +150,32 @@ typedef int NDT_Index_Type;
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
# if defined( _WIN32) && !defined( LIBNODE_STATIC)
|
||||
# ifndef _LIBNODE_C_
|
||||
# define NDD_DLL_API __declspec( dllimport)
|
||||
# else
|
||||
# define NDD_DLL_API __declspec( dllexport)
|
||||
# endif
|
||||
# else
|
||||
# ifdef _LIBNODE_C_
|
||||
# define NDD_DLL_API
|
||||
# else
|
||||
# define NDD_DLL_API extern
|
||||
# endif
|
||||
# endif
|
||||
|
||||
|
||||
|
||||
/* Var Args Manager Macros */
|
||||
|
||||
# define ND_VA_LIST_OPEN( VA_List_Target, VA_List_Source) va_list VA_List_Target; va_copy( VA_List_Target, *va_arg( VA_List_Source, va_list *))
|
||||
# define ND_VA_LIST_CLOSE( VA_List) va_end( VA_List)
|
||||
# define ND_VA_ARG_GET( Arg, VA_List, Type) Type Arg = va_arg( VA_List, Type)
|
||||
|
||||
|
||||
|
||||
/* Manager Template */
|
||||
|
||||
// NDT_Status ND_Example_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Command, va_list *Args_Ptr)
|
||||
@ -478,14 +511,6 @@ typedef int NDT_Index_Type;
|
||||
|
||||
|
||||
|
||||
/* Var Args Manager Macros */
|
||||
|
||||
# define ND_VA_LIST_OPEN( VA_List_Target, VA_List_Source) va_list VA_List_Target; va_copy( VA_List_Target, *va_arg( VA_List_Source, va_list *))
|
||||
# define ND_VA_LIST_CLOSE( VA_List) va_end( VA_List)
|
||||
# define ND_VA_ARG_GET( Arg, VA_List, Type) Type Arg = va_arg( VA_List, Type)
|
||||
|
||||
|
||||
|
||||
/* Manager Commands */
|
||||
|
||||
typedef int NDT_Command;
|
||||
@ -596,14 +621,85 @@ typedef struct NDT_Index
|
||||
|
||||
|
||||
|
||||
/* Handler definitions */
|
||||
|
||||
# define NDD_HANDLER_NAME_LEN 64
|
||||
# define NDD_HANDLER_NAME_SIZE ( NDD_HANDLER_NAME_LEN + 1)
|
||||
|
||||
typedef char *NDT_Handler_Name;
|
||||
|
||||
typedef NDT_Status NDT_Manager_Handler( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command, va_list *);
|
||||
typedef NDT_Status NDT_Init_Handler( );
|
||||
typedef NDT_Status NDT_Alloc_Handler( void **Data_Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, void *User_Ptr);
|
||||
typedef NDT_Status NDT_Free_Handler( void *Data_Ptr, NDT_Root *Root_Ptr, void *User_Ptr);
|
||||
typedef NDT_Status NDT_Open_Handler( NDT_Root *Root_Ptr, char *DS_Name, void *User_Ptr);
|
||||
typedef NDT_Status NDT_Close_Handler( NDT_Root *Root_Ptr, void *User_Ptr);
|
||||
typedef NDT_Status NDT_Lock_Handler( NDT_Root *Root_Ptr, void *User_Ptr);
|
||||
typedef NDT_Status NDT_Unlock_Handler( NDT_Root *Root_Ptr, void *User_Ptr);
|
||||
|
||||
|
||||
|
||||
typedef struct NDT_DataStruct_Handlers
|
||||
{
|
||||
char Manager_Name[ NDD_HANDLER_NAME_SIZE]; /* Manager function name */
|
||||
NDT_Manager_Handler *Manager_Ptr; /* Manager function pointer */
|
||||
char Init_Name[ NDD_HANDLER_NAME_SIZE]; /* Init function name */
|
||||
NDT_Init_Handler *Init_Ptr; /* Init function pointer */
|
||||
char Alloc_Name[ NDD_HANDLER_NAME_SIZE]; /* Alloc function name */
|
||||
NDT_Alloc_Handler *Alloc_Ptr; /* Alloc function pointer */
|
||||
char Free_Name[ NDD_HANDLER_NAME_SIZE]; /* Free function name */
|
||||
NDT_Free_Handler *Free_Ptr; /* Free function pointer */
|
||||
char Open_Name[ NDD_HANDLER_NAME_SIZE]; /* Open function name */
|
||||
NDT_Open_Handler *Open_Ptr; /* Open function pointer */
|
||||
char Close_Name[ NDD_HANDLER_NAME_SIZE]; /* Close function name */
|
||||
NDT_Close_Handler *Close_Ptr; /* Close function pointer */
|
||||
char Lock_Name[ NDD_HANDLER_NAME_SIZE]; /* Lock function name */
|
||||
NDT_Lock_Handler *Lock_Ptr; /* Lock function pointer */
|
||||
char Unlock_Name[ NDD_HANDLER_NAME_SIZE]; /* Unlock function name */
|
||||
NDT_Unlock_Handler *Unlock_Ptr; /* Unlock function pointer */
|
||||
} NDT_DataStruct_Handlers;
|
||||
|
||||
|
||||
|
||||
# ifndef _LIBNODE_C_
|
||||
extern NDT_DataStruct_Handlers NDG_Handlers_Default;
|
||||
# endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Root_Ptr->Manager.Name
|
||||
|
||||
RootPtr->Handlers.Manager_Name
|
||||
|
||||
*/
|
||||
|
||||
/* Root */
|
||||
|
||||
# define NDD_DATASTRUCT_NAME_LEN 64
|
||||
# define NDD_DATASTRUCT_NAME_SIZE ( NDD_DATASTRUCT_NAME_LEN + 1)
|
||||
|
||||
|
||||
|
||||
typedef char *NDT_DataStruct_Name;
|
||||
|
||||
|
||||
|
||||
typedef struct NDT_Root
|
||||
{
|
||||
char Name[ NDD_DATASTRUCT_NAME_SIZE];
|
||||
|
||||
NDT_DataStruct_Handlers Handlers;
|
||||
|
||||
/* Deprecated Start */
|
||||
NDT_Manager *Manager_Ptr; /* Manager function pointer */
|
||||
char Manager_Name[ NDD_MANAGER_NAME_SIZE_MAX]; /* Manager function name */
|
||||
NDT_Allocator *Allocator_Ptr; /* Value allocator function pointer */
|
||||
char Allocator_Name[ NDD_ALLOCATOR_NAME_SIZE_MAX]; /* Value allocator function name */
|
||||
NDT_Deallocator *Deallocator_Ptr; /* Value deallocator function pointer */
|
||||
char Deallocator_Name[ NDD_DEALLOCATOR_NAME_SIZE_MAX]; /* Value deallocator function name */
|
||||
/* Deprecated End */
|
||||
|
||||
short Own_Value; /* Flag indicating if the structure is the node owner */
|
||||
void *User_Ptr; /* User pointer */
|
||||
@ -777,24 +873,6 @@ typedef int NDT_Recursive_Offset;
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
# if defined( _WIN32) && !defined( LIBNODE_STATIC)
|
||||
# ifndef _LIBNODE_C_
|
||||
# define NDD_DLL_API __declspec( dllimport)
|
||||
# else
|
||||
# define NDD_DLL_API __declspec( dllexport)
|
||||
# endif
|
||||
# else
|
||||
# ifndef _LIBNODE_C_
|
||||
# define NDD_DLL_API
|
||||
# else
|
||||
# define NDD_DLL_API extern
|
||||
# endif
|
||||
# endif
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Library initialisation */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
@ -830,20 +908,27 @@ NDD_DLL_API NDT_Status ND_Library_StdErr_Set_C( FILE *);
|
||||
/* Create a new data structure */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* (O) Root_Ptr_Ptr: Pointer adress of the new data structure */
|
||||
/* (I) DataStruct_Name: Name of the data structure */
|
||||
/* (I) Index_Nb: Number of index */
|
||||
/* (I) Index_Type_Ptr: Array of Index type (List, tree, ...) */
|
||||
/* (I) Manager_Name: Manager function name */
|
||||
/* (I) Manager_Ptr: Manager function pointer */
|
||||
/* (I) Handlers_Ptr: Pointer to the data structure handlers */
|
||||
|
||||
/* (I) Allocator_Name: Value allocator function name */
|
||||
/* (I) Allocator_Ptr: Value allocator function pointer */
|
||||
/* (I) Deallocator_Name: Value deallocator function name */
|
||||
/* (I) Deallocator_Ptr: Value deallocator function pointer */
|
||||
|
||||
/* (I) Own_Value: Flag indicating if the structure is the node owner */
|
||||
/* (I) Data_Ptr: User pointer */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
NDD_DLL_API NDT_Status ND_DataStruct_Open_I( NDT_Root **, NDT_Index_Nb, NDT_Index_Type *, NDT_Manager_Name, NDT_Manager *, NDT_Allocator_Name, NDT_Allocator *, NDT_Deallocator_Name, NDT_Deallocator *, short, void *);
|
||||
NDD_DLL_API NDT_Status ND_DataStruct_Open_C( NDT_Root **, NDT_Index_Nb, NDT_Index_Type *, NDT_Manager_Name, NDT_Manager *, NDT_Allocator_Name, NDT_Allocator *, NDT_Deallocator_Name, NDT_Deallocator *, short, void *);
|
||||
//NDD_DLL_API NDT_Status ND_DataStruct_Open_I( NDT_Root **, NDT_Index_Nb, NDT_Index_Type *, NDT_Manager_Name, NDT_Manager *, NDT_Allocator_Name, NDT_Allocator *, NDT_Deallocator_Name, NDT_Deallocator *, short, void *);
|
||||
//NDD_DLL_API NDT_Status ND_DataStruct_Open_C( NDT_Root **, NDT_Index_Nb, NDT_Index_Type *, NDT_Manager_Name, NDT_Manager *, NDT_Allocator_Name, NDT_Allocator *, NDT_Deallocator_Name, NDT_Deallocator *, short, void *);
|
||||
|
||||
NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_DataStruct_Name Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Manager_Name Manager_Name, NDT_Manager *Manager_Ptr, NDT_DataStruct_Handlers *Handlers_Ptr, short Own_Value, void *Data_Ptr);
|
||||
NDT_Status ND_DataStruct_Open_C( NDT_Root **Root_Ptr_Ptr, NDT_DataStruct_Name Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Manager_Name Manager_Name, NDT_Manager *Manager_Ptr, NDT_DataStruct_Handlers *Handlers_Ptr, short Own_Value, void *Data_Ptr);
|
||||
|
||||
|
||||
|
||||
|
152
lib/libnode.c
152
lib/libnode.c
@ -724,7 +724,7 @@ NDT_Status ND_Library_Open_C( int Debug_Mode)
|
||||
{
|
||||
if( Debug_Mode == NDD_TRUE)
|
||||
{
|
||||
if( ( status = ND_DataStruct_Open_I( &(NDG_Base.OpenStruct_Ptr), 1, NDG_Base.OpenStruct_Index_Type, "ND_OpenStruct_Manager", ND_OpenStruct_Manager, NULL, NULL, NULL, NULL, 0, NULL)) != NDS_OK)
|
||||
if( ( status = ND_DataStruct_Open_I( &(NDG_Base.OpenStruct_Ptr), "OpenStruct", 1, NDG_Base.OpenStruct_Index_Type, "ND_OpenStruct_Manager", ND_OpenStruct_Manager, NULL, 0, NULL)) != NDS_OK)
|
||||
{
|
||||
LG_LOG_ERROR_0( "Can't open OpenStruct");
|
||||
|
||||
@ -959,93 +959,77 @@ NDT_Status ND_Index_Open_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_I
|
||||
/* Create a new data structure */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* (O) Root_Ptr_Ptr: Pointer adress of the new sata structure */
|
||||
/* (I) DataStruct_Name: Name of the data structure */
|
||||
/* (I) Index_Nb: Number of index */
|
||||
/* (I) Index_Type_Ptr: Array of Index type (List, tree, ...) */
|
||||
/* (I) Manager_Name: Manager function name */
|
||||
/* (I) Manager_Ptr: Manager function pointer */
|
||||
/* (I) Allocator_Name: Value allocator function name */
|
||||
/* (I) Allocator_Ptr: Value allocator function pointer */
|
||||
/* (I) Deallocator_Name: Value deallocator function name */
|
||||
/* (I) Deallocator_Ptr: Value deallocator function pointer */
|
||||
/* (I) Handlers_Ptr: Pointer to the data structure handlers */
|
||||
/* (I) Own_Value: Flag indicating if the structure is the node owner */
|
||||
/* (I) Data_Ptr: User pointer */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Manager_Name Manager_Name, NDT_Manager *Manager_Ptr,
|
||||
NDT_Allocator_Name Allocator_Name, NDT_Allocator *Allocator_Ptr, NDT_Deallocator_Name Deallocator_Name, NDT_Deallocator *Deallocator_Ptr, short Own_Value, void *Data)
|
||||
//NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Manager_Name Manager_Name, NDT_Manager *Manager_Ptr,
|
||||
// NDT_Allocator_Name Allocator_Name, NDT_Allocator *Allocator_Ptr, NDT_Deallocator_Name Deallocator_Name, NDT_Deallocator *Deallocator_Ptr, short Own_Value, void *Data)
|
||||
|
||||
NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_DataStruct_Name Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Manager_Name Manager_Name, NDT_Manager *Manager_Ptr,
|
||||
NDT_DataStruct_Handlers *Handlers_Ptr, short Own_Value, void *Data_Ptr)
|
||||
{
|
||||
NDT_Status status;
|
||||
NDT_Manager_Name Real_Manager_Name;
|
||||
NDT_Manager *Real_Manager_Ptr;
|
||||
NDT_Allocator_Name Real_Allocator_Name;
|
||||
NDT_Allocator *Real_Allocator_Ptr;
|
||||
NDT_Deallocator_Name Real_Deallocator_Name;
|
||||
NDT_Deallocator *Real_Deallocator_Ptr;
|
||||
NDT_DataStruct_Handlers handlers_target;
|
||||
|
||||
|
||||
if( Handlers_Ptr == NULL)
|
||||
{
|
||||
Handlers_Ptr = &NDG_Handlers_Default;
|
||||
}
|
||||
|
||||
memcpy( &handlers_target, Handlers_Ptr, sizeof( NDT_DataStruct_Handlers));
|
||||
|
||||
|
||||
/* Valeurs par défaut des fonctions d'allocation et de désallocation */
|
||||
|
||||
#if defined(_WIN32)
|
||||
if( ( Manager_Name != NULL) && ( Manager_Ptr == NULL))
|
||||
if( Manager_Name != NULL)
|
||||
{
|
||||
LG_LOG_ERROR_0( "No symbol lookup support, Manager_Ptr shouldn't be NULL");
|
||||
|
||||
return( NDS_ERRAPI);
|
||||
}
|
||||
#endif
|
||||
|
||||
if( ( Manager_Name != NULL) || ( Manager_Ptr != NULL))
|
||||
{
|
||||
Real_Manager_Name = Manager_Name;
|
||||
Real_Manager_Ptr = Manager_Ptr;
|
||||
ND_STRCPY( handlers_target.Manager_Name, Manager_Name, NDD_HANDLER_NAME_SIZE);
|
||||
handlers_target.Manager_Ptr = Manager_Ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
Real_Manager_Name = "ND_Default_Manager";
|
||||
Real_Manager_Ptr = ND_Default_Manager;
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
if( ( Allocator_Name != NULL) && ( Allocator_Ptr == NULL))
|
||||
if( Manager_Ptr != NULL)
|
||||
{
|
||||
LG_LOG_ERROR_0( "No symbol lookup support, Allocator_Ptr shouldn't be NULL");
|
||||
|
||||
return( NDS_ERRAPI);
|
||||
ND_STRCPY( handlers_target.Manager_Name, "", NDD_HANDLER_NAME_SIZE);
|
||||
handlers_target.Manager_Ptr = Manager_Ptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if( ( Allocator_Name != NULL) || ( Allocator_Ptr != NULL))
|
||||
|
||||
/* Call init function */
|
||||
|
||||
/* Complete with default handlers */
|
||||
|
||||
if( ( strlen( handlers_target.Manager_Name) == 0) && ( handlers_target.Manager_Ptr == NULL))
|
||||
{
|
||||
Real_Allocator_Name = Allocator_Name;
|
||||
Real_Allocator_Ptr = Allocator_Ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
Real_Allocator_Name = "ND_Default_Allocator";
|
||||
Real_Allocator_Ptr = ND_Default_Allocator;
|
||||
ND_STRCPY( handlers_target.Manager_Name, "ND_Default_Manager", NDD_HANDLER_NAME_SIZE);
|
||||
handlers_target.Manager_Ptr = ND_Default_Manager;
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
if( ( Deallocator_Name != NULL) && ( Deallocator_Ptr == NULL))
|
||||
if( ( strlen( handlers_target.Alloc_Name) == 0) && ( handlers_target.Alloc_Ptr == NULL))
|
||||
{
|
||||
LG_LOG_ERROR_0( "No symbol lookup support, Deallocator_Ptr shouldn't be NULL");
|
||||
|
||||
return( NDS_ERRAPI);
|
||||
}
|
||||
#endif
|
||||
|
||||
if( ( Deallocator_Name != NULL) || ( Deallocator_Ptr != NULL))
|
||||
{
|
||||
Real_Deallocator_Name = Deallocator_Name;
|
||||
Real_Deallocator_Ptr = Deallocator_Ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
Real_Deallocator_Name = "ND_Default_Deallocator";
|
||||
Real_Deallocator_Ptr = ND_Default_Deallocator;
|
||||
ND_STRCPY( handlers_target.Alloc_Name, "ND_Default_Allocator", NDD_HANDLER_NAME_SIZE);
|
||||
handlers_target.Alloc_Ptr = ND_Default_Allocator;
|
||||
}
|
||||
|
||||
status = ND_Node_Root_Alloc( Root_Ptr_Ptr, Index_Nb, Type_Ptr, Real_Manager_Name, Real_Manager_Ptr, Real_Allocator_Name, Real_Allocator_Ptr, Real_Deallocator_Name, Real_Deallocator_Ptr, Own_Value, Data);
|
||||
if( ( strlen( handlers_target.Free_Name) == 0) && ( handlers_target.Free_Ptr == NULL))
|
||||
{
|
||||
ND_STRCPY( handlers_target.Free_Name, "ND_Default_Deallocator", NDD_HANDLER_NAME_SIZE);
|
||||
handlers_target.Free_Ptr = ND_Default_Deallocator;
|
||||
}
|
||||
|
||||
|
||||
// status = ND_Node_Root_Alloc( Root_Ptr_Ptr, Index_Nb, Type_Ptr, Real_Manager_Name, Real_Manager_Ptr, Real_Allocator_Name, Real_Allocator_Ptr, Real_Deallocator_Name, Real_Deallocator_Ptr, Own_Value, Data);
|
||||
|
||||
status = ND_Node_Root_Alloc( Root_Ptr_Ptr, Name, Index_Nb, Type_Ptr, &handlers_target, Own_Value, Data_Ptr);
|
||||
|
||||
if( ND_ERROR( status)) return( status);
|
||||
|
||||
@ -1072,15 +1056,18 @@ NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_N
|
||||
/* (I) Data_Ptr: User pointer */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
NDT_Status ND_DataStruct_Open_C( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Manager_Name Manager_Name, NDT_Manager *Manager_Ptr,
|
||||
NDT_Allocator_Name Allocator_Name, NDT_Allocator *Allocator_Ptr, NDT_Deallocator_Name Deallocator_Name, NDT_Deallocator *Deallocator_Ptr, short Own_Value, void *Data_Ptr)
|
||||
//NDT_Status ND_DataStruct_Open_C( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Manager_Name Manager_Name, NDT_Manager *Manager_Ptr,
|
||||
// NDT_Allocator_Name Allocator_Name, NDT_Allocator *Allocator_Ptr, NDT_Deallocator_Name Deallocator_Name, NDT_Deallocator *Deallocator_Ptr, short Own_Value, void *Data_Ptr)
|
||||
|
||||
NDT_Status ND_DataStruct_Open_C( NDT_Root **Root_Ptr_Ptr, NDT_DataStruct_Name Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Manager_Name Manager_Name, NDT_Manager *Manager_Ptr,
|
||||
NDT_DataStruct_Handlers *Handlers_Ptr, short Own_Value, void *Data_Ptr)
|
||||
{
|
||||
NDT_Status status;
|
||||
|
||||
|
||||
ND_LIBNODE_OPEN_CHECK();
|
||||
|
||||
if( ( status = ND_DataStruct_Open_I( Root_Ptr_Ptr, Index_Nb, Type_Ptr, Manager_Name, Manager_Ptr, Allocator_Name, Allocator_Ptr, Deallocator_Name, Deallocator_Ptr, Own_Value, Data_Ptr)) != NDS_OK)
|
||||
if( ( status = ND_DataStruct_Open_I( Root_Ptr_Ptr, Name, Index_Nb, Type_Ptr, Manager_Name, Manager_Ptr, Handlers_Ptr, Own_Value, Data_Ptr)) != NDS_OK)
|
||||
{
|
||||
return( status);
|
||||
}
|
||||
@ -2151,11 +2138,16 @@ NDT_Status ND_DataStruct_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Recu
|
||||
offset, version_name);
|
||||
*/
|
||||
|
||||
LG_LOG_INFO_8( "%sRoot: (%s%p)\tIndex Nb: (%d)\tIndex Open Count: (%d)\tManager: (%s%p) [%s]",
|
||||
offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr, Root_Ptr->Index_Nb, Root_Ptr->Index_Open_Count, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Manager_Ptr, Root_Ptr->Manager_Name);
|
||||
LG_LOG_INFO_9( "%sAllocator: (%s%p) [%s]\tDeallocator: (%s%p) [%s]\tUser: (%s%p)",
|
||||
offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Allocator_Ptr, Root_Ptr->Allocator_Name, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Deallocator_Ptr, Root_Ptr->Deallocator_Name, NDD_PRINTF_PTR_PREFIX, Root_Ptr->User_Ptr);
|
||||
LG_LOG_INFO_2( "%sManager Version: [%s]", offset, version_name);
|
||||
LG_LOG_INFO_6( "%sRoot: (%s%p)\tName: [%s]\tIndex Nb: (%d)\tIndex Open Count: (%d)",
|
||||
offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr, Root_Ptr->Name, Root_Ptr->Index_Nb, Root_Ptr->Index_Open_Count);
|
||||
LG_LOG_INFO_13( "%sManager: (%s%p) [%s]\tInit: (%s%p) [%s]\tAlloc: (%s%p) [%s]\tFree: (%s%p) [%s]",
|
||||
offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Handlers.Manager_Ptr, Root_Ptr->Handlers.Manager_Name, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Handlers.Init_Ptr, Root_Ptr->Handlers.Init_Name,
|
||||
NDD_PRINTF_PTR_PREFIX, Root_Ptr->Handlers.Alloc_Ptr, Root_Ptr->Handlers.Alloc_Name, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Handlers.Free_Ptr, Root_Ptr->Handlers.Free_Name);
|
||||
LG_LOG_INFO_13( "%sOpen: (%s%p) [%s]\tClose: (%s%p) [%s]\tLock: (%s%p) [%s]\tUnlock: (%s%p) [%s]",
|
||||
offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Handlers.Open_Ptr, Root_Ptr->Handlers.Open_Name, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Handlers.Close_Ptr, Root_Ptr->Handlers.Close_Name,
|
||||
NDD_PRINTF_PTR_PREFIX, Root_Ptr->Handlers.Lock_Ptr, Root_Ptr->Handlers.Lock_Name, NDD_PRINTF_PTR_PREFIX, Root_Ptr->Handlers.Unlock_Ptr, Root_Ptr->Handlers.Unlock_Name);
|
||||
LG_LOG_INFO_4( "%sUser: (%s%p)\tManager Version: [%s]",
|
||||
offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr->User_Ptr, version_name);
|
||||
LG_LOG_INFO_0( "");
|
||||
}
|
||||
|
||||
@ -3898,15 +3890,32 @@ NDT_Status ND_Index_Clear( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id)
|
||||
/* (I) Data : pointeur de données utiles à l'allocateur */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
NDT_Status ND_Node_Root_Alloc( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, char *Manager_Name, NDT_Manager *Manager_Ptr, char *Allocator_Name, NDT_Allocator *Allocator_Ptr, char *Deallocator_Name, NDT_Deallocator *Deallocator_Ptr, short Own_Value, void *Data_Ptr)
|
||||
// NDT_Status ND_Node_Root_Alloc( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, char *Manager_Name, NDT_Manager *Manager_Ptr, char *Allocator_Name, NDT_Allocator *Allocator_Ptr, char *Deallocator_Name, NDT_Deallocator *Deallocator_Ptr, short Own_Value, void *Data_Ptr)
|
||||
|
||||
NDT_Status ND_Node_Root_Alloc( NDT_Root **Root_Ptr_Ptr, NDT_DataStruct_Name Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_DataStruct_Handlers *Handlers_Ptr, short Own_Value, void *Data_Ptr)
|
||||
{
|
||||
NDT_Status status;
|
||||
NDT_Index_Id index_id;
|
||||
|
||||
|
||||
status = ND_Allocator_Exec_I( (void **)Root_Ptr_Ptr, NULL, ( sizeof( NDT_Root) + sizeof(NDT_Index) * (Index_Nb - 1)), Allocator_Name, Allocator_Ptr, Data_Ptr);
|
||||
status = ND_Allocator_Exec_I( (void **)Root_Ptr_Ptr, NULL, ( sizeof( NDT_Root) + sizeof(NDT_Index) * (Index_Nb - 1)), Handlers_Ptr->Alloc_Name, Handlers_Ptr->Alloc_Ptr, Data_Ptr);
|
||||
if( ND_ERROR(status)) return( status);
|
||||
|
||||
ND_STRCPY( ( *Root_Ptr_Ptr)->Name, Name, NDD_DATASTRUCT_NAME_SIZE);
|
||||
|
||||
memcpy( &( ( *Root_Ptr_Ptr)->Handlers), Handlers_Ptr, sizeof( NDT_DataStruct_Handlers));
|
||||
|
||||
/* To be removed... */
|
||||
ND_STRCPY( ( *Root_Ptr_Ptr)->Manager_Name, ( *Root_Ptr_Ptr)->Handlers.Manager_Name, NDD_HANDLER_NAME_SIZE);
|
||||
( *Root_Ptr_Ptr)->Manager_Ptr = ( *Root_Ptr_Ptr)->Handlers.Manager_Ptr;
|
||||
|
||||
ND_STRCPY( ( *Root_Ptr_Ptr)->Allocator_Name, ( *Root_Ptr_Ptr)->Handlers.Alloc_Name, NDD_HANDLER_NAME_SIZE);
|
||||
( *Root_Ptr_Ptr)->Allocator_Ptr = ( *Root_Ptr_Ptr)->Handlers.Alloc_Ptr;
|
||||
|
||||
ND_STRCPY( ( *Root_Ptr_Ptr)->Deallocator_Name, ( *Root_Ptr_Ptr)->Handlers.Free_Name, NDD_HANDLER_NAME_SIZE);
|
||||
( *Root_Ptr_Ptr)->Deallocator_Ptr = ( *Root_Ptr_Ptr)->Handlers.Free_Ptr;
|
||||
|
||||
/*
|
||||
if( strlen( Manager_Name) > NDD_MANAGER_NAME_LEN_MAX) return( NDS_ERRAPI);
|
||||
strcpy( ( *Root_Ptr_Ptr)->Manager_Name, Manager_Name);
|
||||
( *Root_Ptr_Ptr)->Manager_Ptr = Manager_Ptr;
|
||||
@ -3918,6 +3927,7 @@ NDT_Status ND_Node_Root_Alloc( NDT_Root **Root_Ptr_Ptr, NDT_Index_Nb Index_Nb,
|
||||
if( strlen( Deallocator_Name) > NDD_DEALLOCATOR_NAME_LEN_MAX) return( NDS_ERRAPI);
|
||||
strcpy( ( *Root_Ptr_Ptr)->Deallocator_Name, Deallocator_Name);
|
||||
( *Root_Ptr_Ptr)->Deallocator_Ptr = Deallocator_Ptr;
|
||||
*/
|
||||
|
||||
( *Root_Ptr_Ptr)->Own_Value = Own_Value;
|
||||
( *Root_Ptr_Ptr)->User_Ptr = Data_Ptr;
|
||||
|
@ -118,6 +118,37 @@ NDT_Base NDG_Base =
|
||||
};
|
||||
|
||||
|
||||
|
||||
NDT_DataStruct_Handlers NDG_Handlers_Default =
|
||||
{
|
||||
"", /* Default Manager function name */
|
||||
NULL, /* Default Manager function pointer */
|
||||
"", /* Default Init function name */
|
||||
NULL, /* Default Init function pointer */
|
||||
|
||||
// "ND_Default_Allocator", /* Default Alloc function name */
|
||||
// ND_Default_Allocator, /* Default Alloc function pointer */
|
||||
// "ND_Default_Deallocator", /* Default Free function name */
|
||||
// ND_Default_Deallocator, /* Default Free function pointer */
|
||||
|
||||
"", /* Default Alloc function name */
|
||||
NULL, /* Default Alloc function pointer */
|
||||
"", /* Default Free function name */
|
||||
NULL, /* Default Free function pointer */
|
||||
"", /* Default Open function name */
|
||||
NULL, /* Default Open function pointer */
|
||||
"", /* Default Close function name */
|
||||
NULL, /* Default Close function pointer */
|
||||
"", /* Default Lock function name */
|
||||
NULL, /* Default Lock function pointer */
|
||||
"", /* Default Unlock function name */
|
||||
NULL /* Default Unlock function pointer */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------*/
|
||||
/* */
|
||||
/*------------------------------------------------------------------------------*/
|
||||
@ -188,15 +219,21 @@ NDT_Status ND_Node_Free( NDT_Root *, NDT_Node *);
|
||||
NDT_Status ND_Index_Clear( NDT_Root *, NDT_Index_Id);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Création de la racine d'une structure de données quelconque */
|
||||
/* Alocate and initialize a new data structure root node */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* (O) New_Root : adresse du pointeur sur la nouvelle racine */
|
||||
/* (I) Type : type de la structure de données */
|
||||
/* (I) Allocater : pointeur vers la fonction d'allocation */
|
||||
/* (I) Deallocater : pointeur vers la fonction de désallocation */
|
||||
/* (I) Data : pointeur de données utiles à l'allocateur */
|
||||
/* (O) Root_Ptr_Ptr: Pointer adress of the new sata structure */
|
||||
/* (I) DataStruct_Name: Name of the data structure */
|
||||
/* (I) Index_Nb: Number of index */
|
||||
/* (I) Index_Type_Ptr: Array of Index type (List, tree, ...) */
|
||||
/* (I) Handlers_Ptr: Pointer to the data structure handlers */
|
||||
/* (I) Own_Value: Flag indicating if the structure is the node owner */
|
||||
/* (I) Data_Ptr: User pointer */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
NDT_Status ND_Node_Root_Alloc( NDT_Root **, NDT_Index_Nb, NDT_Index_Type[], char *, NDT_Manager *, char *, NDT_Allocator *, char *, NDT_Deallocator *, short, void *);
|
||||
//NDT_Status ND_Node_Root_Alloc( NDT_Root **, NDT_Index_Nb, NDT_Index_Type[], char *, NDT_Manager *, char *, NDT_Allocator *, char *, NDT_Deallocator *, short, void *);
|
||||
|
||||
NDT_Status ND_Node_Root_Alloc( NDT_Root **Root_Ptr_Ptr, NDT_DataStruct_Name Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_DataStruct_Handlers *Handlers_Ptr, short Own_Value, void *Data_Ptr);
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Destruction d'une racine */
|
||||
|
@ -838,11 +838,13 @@ void Command_Exec( NDT_Root **DS_Ptr_Ptr, FILE *File_Output, int Choice, cha
|
||||
t_start( t_exec);
|
||||
if( sub_choice == 0)
|
||||
{
|
||||
ND_DataStruct_Open( DS_Ptr_Ptr, INDEX_NB, idx_type_tab, "Module_Manager", Module_Manager, NULL, NULL, NULL, NULL, NDD_TRUE, NULL);
|
||||
// ND_DataStruct_Open( DS_Ptr_Ptr, INDEX_NB, idx_type_tab, "Module_Manager", Module_Manager, NULL, NULL, NULL, NULL, NDD_TRUE, NULL);
|
||||
ND_DataStruct_Open( DS_Ptr_Ptr, "NDBench", INDEX_NB, idx_type_tab, "Module_Manager", Module_Manager, NULL, NDD_TRUE, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
ND_DataStruct_Open( DS_Ptr_Ptr, INDEX_NB, idx_type_tab, "Module_Manager", NULL, NULL, NULL, NULL, NULL, NDD_TRUE, NULL);
|
||||
// ND_DataStruct_Open( DS_Ptr_Ptr, INDEX_NB, idx_type_tab, "Module_Manager", NULL, NULL, NULL, NULL, NULL, NDD_TRUE, NULL);
|
||||
ND_DataStruct_Open( DS_Ptr_Ptr, "NDBench", INDEX_NB, idx_type_tab, "Module_Manager", NULL, NULL, NDD_TRUE, NULL);
|
||||
}
|
||||
t_stop( t_exec);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user