- New Handler tab implementation.

This commit is contained in:
Arnaud G. GIBERT 2024-05-26 16:27:29 +02:00
parent 2d259e4f2f
commit e569611b1c
3 changed files with 254 additions and 93 deletions

View File

@ -623,54 +623,83 @@ typedef struct NDT_Index
/* Handler definitions */
# define NDD_HANDLER_NAME_LEN 64
# define NDD_HANDLER_NAME_SIZE ( NDD_HANDLER_NAME_LEN + 1)
typedef short NDT_Handler_Id;
typedef short NDT_Handler_Nb;
typedef char *NDT_Handler_Name;
# define NDD_HANDLER_ID_MANAGER ( NDT_Handler_Id)0
# define NDD_HANDLER_ID_INIT ( NDT_Handler_Id)1
# define NDD_HANDLER_ID_ALLOC ( NDT_Handler_Id)2
# define NDD_HANDLER_ID_FREE ( NDT_Handler_Id)3
# define NDD_HANDLER_ID_OPEN ( NDT_Handler_Id)4
# define NDD_HANDLER_ID_CLOSE ( NDT_Handler_Id)5
# define NDD_HANDLER_ID_LOCK ( NDT_Handler_Id)6
# define NDD_HANDLER_ID_UNLOCK ( NDT_Handler_Id)7
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);
# define NDD_HANDLER_ID_NB ( NDT_Handler_Nb)8
# define NDD_HANDLER_NB NDD_HANDLER_ID_NB
# 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_Handler_Function)( void);
typedef struct NDT_DataStruct_Handlers
typedef struct NDT_Handler
{
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;
NDT_Handler_Name Name[ NDD_MANAGER_NAME_SIZE_MAX];
NDT_Handler_Function *Ptr;
} NDT_Handler;
# define NDD_HANDLER_TAB_SIZE ( sizeof( NDT_Handler) * NDD_HANDLER_NB)
# define NDD_HANDLER_SET( Handler_Ptr, Function_Name, Function_Ptr) ND_STRCPY( ( Handler_Ptr).Name, (Function_Name), NDD_HANDLER_NAME_SIZE); \
( Handler_Ptr).Ptr = (NDT_Handler_Function *)(Function_Ptr);
/*
typedef NDT_Status NDT_Handler_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command, va_list *);
typedef NDT_Status NDT_Handler_Init( );
typedef NDT_Status NDT_Handler_Alloc( void **Data_Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, void *User_Ptr);
typedef NDT_Status NDT_Handler_Free( void *Data_Ptr, NDT_Root *Root_Ptr, void *User_Ptr);
typedef NDT_Status NDT_Handler_Open( NDT_Root *Root_Ptr, char *DS_Name, void *User_Ptr);
typedef NDT_Status NDT_Handler_Close( NDT_Root *Root_Ptr, void *User_Ptr);
typedef NDT_Status NDT_Handler_Lock( NDT_Root *Root_Ptr, void *User_Ptr);
typedef NDT_Status NDT_Handler_Unlock( NDT_Root *Root_Ptr, void *User_Ptr);
*/
//typedef struct NDT_DataStruct_Handlers
//{
// char Manager_Name[ NDD_HANDLER_NAME_SIZE]; /* Manager function name */
// NDT_Handler_Manager *Manager_Ptr; /* Manager function pointer */
// char Init_Name[ NDD_HANDLER_NAME_SIZE]; /* Init function name */
// NDT_Handler_Init *Init_Ptr; /* Init function pointer */
// char Alloc_Name[ NDD_HANDLER_NAME_SIZE]; /* Alloc function name */
// NDT_Handler_Alloc *Alloc_Ptr; /* Alloc function pointer */
// char Free_Name[ NDD_HANDLER_NAME_SIZE]; /* Free function name */
// NDT_Handler_Free *Free_Ptr; /* Free function pointer */
// char Open_Name[ NDD_HANDLER_NAME_SIZE]; /* Open function name */
// NDT_Handler_Open *Open_Ptr; /* Open function pointer */
// char Close_Name[ NDD_HANDLER_NAME_SIZE]; /* Close function name */
// NDT_Handler_Close *Close_Ptr; /* Close function pointer */
// char Lock_Name[ NDD_HANDLER_NAME_SIZE]; /* Lock function name */
// NDT_Handler_Lock *Lock_Ptr; /* Lock function pointer */
// char Unlock_Name[ NDD_HANDLER_NAME_SIZE]; /* Unlock function name */
// NDT_Handler_Unlock *Unlock_Ptr; /* Unlock function pointer */
//} NDT_DataStruct_Handlers;
# ifndef _LIBNODE_C_
extern NDT_DataStruct_Handlers NDG_Handlers_Default;
extern NDT_Handler NDG_Handler_Tab_Default[ NDD_HANDLER_ID_NB];
# endif
/*
Root_Ptr->Manager.Name
RootPtr->Handlers.Manager_Name
*/
@ -688,9 +717,12 @@ typedef char *NDT_DataStruct_Name;
typedef struct NDT_Root
{
char Name[ NDD_DATASTRUCT_NAME_SIZE];
char Name[ NDD_DATASTRUCT_NAME_SIZE];
NDT_DataStruct_Handlers Handlers;
long Root_Size; /* Root node total size */
// NDT_DataStruct_Handlers Handlers;
NDT_Handler Handler_Tab[ NDD_HANDLER_ID_NB];
/* Deprecated Start */
NDT_Manager *Manager_Ptr; /* Manager function pointer */
@ -702,6 +734,7 @@ typedef struct NDT_Root
/* Deprecated End */
short Own_Value; /* Flag indicating if the structure is the node owner */
void *User_Ptr; /* User pointer */
NDT_Index_Nb Index_Nb;
@ -927,8 +960,8 @@ NDD_DLL_API NDT_Status ND_Library_StdErr_Set_C( FILE *);
//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);
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_Handler *Handler_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_Handler *Handler_Ptr, short Own_Value, void *Data_Ptr);
@ -1411,6 +1444,17 @@ NDD_DLL_API NDT_Status ND_Free_C( void *, NDT_Root *, void *);
/*----------------------------------------------------------------------------*/
/* Initialize an handlers struture to default value */
/*----------------------------------------------------------------------------*/
/* (I) Handlers_Ptr: Handlers pointer to be initialized */
/*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Handlers_Init_I( NDT_Handler *Handlers_Tab);
NDD_DLL_API NDT_Status ND_Handlers_Init_C( NDT_Handler *Handlers_Tab);
/*----------------------------------------------------------------------------*/
/* Execute an allocator function */
/*----------------------------------------------------------------------------*/

View File

@ -973,33 +973,40 @@ NDT_Status ND_Index_Open_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_I
// 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_Handler *Handler_Tab, short Own_Value, void *Data_Ptr)
{
NDT_Status status;
NDT_DataStruct_Handlers handlers_target;
NDT_Status status;
NDT_Handler handler_target_tab[ NDD_HANDLER_NB];
NDT_Handler_Id handler_id;
if( Handlers_Ptr == NULL)
if( Handler_Tab == NULL)
{
Handlers_Ptr = &NDG_Handlers_Default;
Handler_Tab = NDG_Handler_Tab_Default;
}
memcpy( &handlers_target, Handlers_Ptr, sizeof( NDT_DataStruct_Handlers));
memcpy( &handler_target_tab, Handler_Tab, NDD_HANDLER_TAB_SIZE);
/* Valeurs par défaut des fonctions d'allocation et de désallocation */
if( Manager_Name != NULL)
{
ND_STRCPY( handlers_target.Manager_Name, Manager_Name, NDD_HANDLER_NAME_SIZE);
handlers_target.Manager_Ptr = Manager_Ptr;
NDD_HANDLER_SET( handler_target_tab[ NDD_HANDLER_ID_MANAGER], Manager_Name, Manager_Ptr);
// ND_STRCPY( handlers_target.Manager_Name, Manager_Name, NDD_HANDLER_NAME_SIZE);
// handlers_target.Manager_Ptr = Manager_Ptr;
// ND_Handler_Set( handlers_target, NDD_HANDLER_MANAGER, Manager_Name, Manager_Ptr);
}
else
{
if( Manager_Ptr != NULL)
{
ND_STRCPY( handlers_target.Manager_Name, "", NDD_HANDLER_NAME_SIZE);
handlers_target.Manager_Ptr = Manager_Ptr;
NDD_HANDLER_SET( handler_target_tab[ NDD_HANDLER_ID_MANAGER], "", Manager_Ptr);
// ND_STRCPY( handlers_target.Manager_Name, "", NDD_HANDLER_NAME_SIZE);
// handlers_target.Manager_Ptr = Manager_Ptr;
}
}
@ -1008,10 +1015,29 @@ NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_DataStruct_Name
/* Complete with default handlers */
for( handler_id = 0; handler_id < NDD_HANDLER_ID_NB; handler_id++)
{
if( ( strlen( handler_target_tab[ handler_id].Name) == 0) && ( handler_target_tab[ handler_id].Ptr == NULL))
{
NDD_HANDLER_SET( handler_target_tab[ handler_id], NDG_Handler_Tab_Default[ handler_id].Name, NDG_Handler_Tab_Default[ handler_id].Ptr);
}
}
/*
NDG_Handler_Tab_Default[ handler_id]
if( ( strlen( handlers_target.Manager_Name) == 0) && ( handlers_target.Manager_Ptr == NULL))
{
ND_STRCPY( handlers_target.Manager_Name, "ND_Default_Manager", NDD_HANDLER_NAME_SIZE);
handlers_target.Manager_Ptr = ND_Default_Manager;
// ND_STRCPY( handlers_target.Manager_Name, "ND_Default_Manager", NDD_HANDLER_NAME_SIZE);
// handlers_target.Manager_Ptr = ND_Default_Manager;
ND_STRCPY( handler_tab_target[ NDD_HANDLER_ID_MANAGER].Name, "ND_Default_Manager", NDD_HANDLER_NAME_SIZE);
handler_tab_target[NDD_HANDLER_ID_MANAGER].Ptr = ND_Default_Manager;
NDD_HANDLER_SET( handler_tab_target[ NDD_HANDLER_ID_MANAGER], "ND_Default_Manager", ND_Default_Manager);
ND_Handler_Set( &handlers_target, NDD_HANDLER_MANAGER, "ND_Default_Manager", ND_Default_Manager);
}
if( ( strlen( handlers_target.Alloc_Name) == 0) && ( handlers_target.Alloc_Ptr == NULL))
@ -1026,10 +1052,10 @@ NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_DataStruct_Name
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);
status = ND_Node_Root_Alloc( Root_Ptr_Ptr, Name, Index_Nb, Type_Ptr, handler_target_tab, Own_Value, Data_Ptr);
if( ND_ERROR( status)) return( status);
@ -1060,14 +1086,14 @@ NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_DataStruct_Name
// 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_Handler *Handler_Tab, short Own_Value, void *Data_Ptr)
{
NDT_Status status;
ND_LIBNODE_OPEN_CHECK();
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)
if( ( status = ND_DataStruct_Open_I( Root_Ptr_Ptr, Name, Index_Nb, Type_Ptr, Manager_Name, Manager_Ptr, Handler_Tab, Own_Value, Data_Ptr)) != NDS_OK)
{
return( status);
}
@ -2140,14 +2166,22 @@ NDT_Status ND_DataStruct_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Recu
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_13( "%sManager: (%s%p) [%s]\tInit: (%s%p) [%s]\tAlloc: (%s%p) [%s]\tFree: (%s%p) [%s]", offset,
NDD_PRINTF_PTR_PREFIX, Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_MANAGER].Ptr, Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_MANAGER].Name,
NDD_PRINTF_PTR_PREFIX, Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_INIT ].Ptr, Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_INIT ].Name,
NDD_PRINTF_PTR_PREFIX, Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_ALLOC ].Ptr, Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_ALLOC ].Name,
NDD_PRINTF_PTR_PREFIX, Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_FREE ].Ptr, Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_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->Handler_Tab[ NDD_HANDLER_ID_OPEN ].Ptr, Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_OPEN ].Name,
NDD_PRINTF_PTR_PREFIX, Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_CLOSE ].Ptr, Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_CLOSE ].Name,
NDD_PRINTF_PTR_PREFIX, Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_LOCK ].Ptr, Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_LOCK ].Name,
NDD_PRINTF_PTR_PREFIX, Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_UNLOCK].Ptr, Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_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( "");
}
@ -3604,6 +3638,57 @@ NDT_Status ND_Manager_Exec_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_
/*----------------------------------------------------------------------------*/
/* Initialize an handlers struture to default value */
/*----------------------------------------------------------------------------*/
/* (I) Handlers_Ptr: Handlers pointer to be initialized */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handlers_Init_I( NDT_Handler *Handler_Tab)
{
}
/*----------------------------------------------------------------------------*/
/* Execute an allocator function */
/*----------------------------------------------------------------------------*/
/* (O) Value_Ptr_Ptr: Value pointer address */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Size: Allocation size */
/* (I) Allocator_Name: Value allocator function name */
/* (I) Allocator_Ptr: Value allocator function pointer */
/* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Init_Exec_I( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, NDT_Allocator_Name Allocator_Name, NDT_Allocator *Allocator_Ptr, void *Data_Ptr)
{
NDT_Allocator *allocator_ptr;
if( Allocator_Ptr != NULL)
{
allocator_ptr = Allocator_Ptr;
}
else
{
if( ND_Symbol_Find( (void **)&allocator_ptr, Allocator_Name) != NDS_OK)
{
LG_LOG_ERROR_0( "Cant't find allocator function");
return( NDS_KO);
}
}
return( allocator_ptr( Ptr_Ptr, Root_Ptr, Size, Data_Ptr));
}
/*----------------------------------------------------------------------------*/
/* Execute an allocator function */
/*----------------------------------------------------------------------------*/
@ -3892,28 +3977,28 @@ NDT_Status ND_Index_Clear( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id)
// 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 ND_Node_Root_Alloc( NDT_Root **Root_Ptr_Ptr, NDT_DataStruct_Name Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Type_Ptr, NDT_Handler *Handler_Tab, 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)), Handlers_Ptr->Alloc_Name, Handlers_Ptr->Alloc_Ptr, Data_Ptr);
status = ND_Allocator_Exec_I( (void **)Root_Ptr_Ptr, NULL, ( sizeof( NDT_Root) + sizeof(NDT_Index) * (Index_Nb - 1)), Handler_Tab[ NDD_HANDLER_ID_ALLOC].Name, (NDT_Allocator *)Handler_Tab[ NDD_HANDLER_ID_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));
memcpy( &( ( *Root_Ptr_Ptr)->Handler_Tab), Handler_Tab, NDD_HANDLER_TAB_SIZE);
/* 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)->Manager_Name, ( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_MANAGER].Name, NDD_HANDLER_NAME_SIZE);
( *Root_Ptr_Ptr)->Manager_Ptr = (NDT_Manager *)( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_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)->Allocator_Name, ( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_ALLOC].Name, NDD_HANDLER_NAME_SIZE);
( *Root_Ptr_Ptr)->Allocator_Ptr = (NDT_Allocator *)( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_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;
ND_STRCPY( ( *Root_Ptr_Ptr)->Deallocator_Name, ( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_FREE].Name, NDD_HANDLER_NAME_SIZE);
( *Root_Ptr_Ptr)->Deallocator_Ptr = (NDT_Deallocator *)( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_FREE].Ptr;
/*
if( strlen( Manager_Name) > NDD_MANAGER_NAME_LEN_MAX) return( NDS_ERRAPI);
@ -5415,3 +5500,6 @@ void ND_Signal_Trap( int Sig_Num)
longjmp( NDG_Base.SigLongJmp_Env, 1);
#endif
}

View File

@ -119,31 +119,30 @@ 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 */
};
//{
// "", /* 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 */
//};
@ -231,7 +230,7 @@ NDT_Status ND_Index_Clear( NDT_Root *, NDT_Index_Id);
/*----------------------------------------------------------------------------*/
//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);
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_Handler *Handler_Tab, short Own_Value, void *Data_Ptr);
@ -351,6 +350,36 @@ NDT_Status ND_List_Sort( NDT_Root *, NDT_Index_Id);
/*----------------------------------------------------------------------------*/
/* Post prototype global variable definitions */
/*----------------------------------------------------------------------------*/
NDT_Handler NDG_Handler_Tab_Default[ NDD_HANDLER_NB] =
{
{ "", /* 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 */
(NDT_Handler_Function *)ND_Default_Allocator}, /* Default Alloc function pointer */
{ "ND_Default_Deallocator", /* Default Free function name */
(NDT_Handler_Function *)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 */
};
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/