- Implement Open, Close, Info, Lock & Unlock default handlers,

- Implement Open, Close, Info, Lock & Unlock exec function handlers,
- Add Init & Open handler calls in ND_DataStruct_Open(),
- Add Info handler call in ND_DataStruct_Info_Print_I(),
- Update ND_Node_Root_Alloc().
This commit is contained in:
Arnaud G. GIBERT 2024-05-27 22:47:24 +02:00
parent e569611b1c
commit c45466c893
3 changed files with 1056 additions and 310 deletions

View File

@ -37,6 +37,7 @@
# include <stdio.h> # include <stdio.h>
# include <string.h> # include <string.h>
# include <stdarg.h> # include <stdarg.h>
# include <stdbool.h>
# ifdef _LIBVER_SUPPORT # ifdef _LIBVER_SUPPORT
# include <ver.h> # include <ver.h>
@ -46,6 +47,19 @@
# 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
@ -66,11 +80,85 @@
/*----------------------------------------------------------------------------*/
/* Predefinition */
/*----------------------------------------------------------------------------*/
typedef struct NDT_Node NDT_Node;
typedef struct NDT_Handler NDT_Handler;
typedef struct NDT_Index NDT_Index;
typedef struct NDT_Root NDT_Root;
/*----------------------------------------------------------------------------*/
/* Manager or Functions Return Codes */
/*----------------------------------------------------------------------------*/
typedef int NDT_Status;
# define ND_ERROR(s) ( ( s) <= 0) /* All negative or 0 status are errors */
# define NDS_OK 1
# define NDS_KO 0
# define NDS_YES 1
# define NDS_NO 0
# define NDS_EQUAL 1
# define NDS_GREATER 2
# define NDS_LOWER 3
# define NDS_ERRMEM -1 /* Memory allocation problem */
# define NDS_ERRAPI -2 /* Bad API usage */
/*----------------------------------------------------------------------------*/
/* Print out definitions */
/*----------------------------------------------------------------------------*/
typedef int NDT_Recursive_Mode;
typedef int NDT_Recursive_Depth;
typedef int NDT_Recursive_Offset;
# define NDD_RECURSIVE_MODE_UNKNOWN ( NDT_Recursive_Mode)0x00
# define NDD_RECURSIVE_MODE_PARENT ( NDT_Recursive_Mode)0x01
# define NDD_RECURSIVE_MODE_CHILD ( NDT_Recursive_Mode)0x02
# define NDD_RECURSIVE_MODE_PARENT_CHILD ( NDT_Recursive_Mode)0x03
# define ND_RECURSIVE_PARENT_IS(m) ( m & NDD_RECURSIVE_MODE_PARENT)
# define ND_RECURSIVE_CHILD_IS(m) ( m & NDD_RECURSIVE_MODE_CHILD)
# define ND_RECURSIVE_PRINT_OFFSET 8
/*----------------------------------------------------------------------------*/
/* Indexes definitions */
/*----------------------------------------------------------------------------*/
/* /*
Default allowed maximum depth between tree branches before rebalancing Default allowed maximum depth between tree branches before rebalancing
*/ */
# define DEF_MAX_DIF 100 # define DEF_MAX_DIF 100
typedef short NDT_Index_Id;
typedef short NDT_Index_Nb;
# define NDD_INDEX_UNKNOWN (NDT_Index_Id)-1
# define NDD_INDEX_PRIMARY (NDT_Index_Id) 0
/* Types de structure */ /* Types de structure */
typedef short NDT_Root_Type; typedef short NDT_Root_Type;
typedef int NDT_Index_Type; typedef int NDT_Index_Type;
@ -152,22 +240,30 @@ typedef int NDT_Index_Type;
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
# if defined( _WIN32) && !defined( LIBNODE_STATIC)
# ifndef _LIBNODE_C_ typedef struct NDT_Index
# define NDD_DLL_API __declspec( dllimport) {
# else NDT_Index_Type Type; /* Structure Type (Queue, Stack, Tree, ... ) */
# define NDD_DLL_API __declspec( dllexport)
# endif long Node_Number; /* Number of node in the structure */
# else long Min_Depth; /* Minimum tree depth */
# ifdef _LIBNODE_C_ long Max_Depth; /* Maximum tree depth */
# define NDD_DLL_API long Max_Dif; /* Maximum allowed depth between tree branches before rebalancing */
# else long Nb_Equ; /* Rebalancing count */
# define NDD_DLL_API extern struct NDT_Node *Head; /* Head node */
# endif struct NDT_Node *Tail; /* Tail node */
# endif struct NDT_Node *Save; /* Save pointer (Used by restore function) */
} NDT_Index;
/*----------------------------------------------------------------------------*/
/* Mangers definitions */
/*----------------------------------------------------------------------------*/
/* Var Args Manager Macros */ /* 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_OPEN( VA_List_Target, VA_List_Source) va_list VA_List_Target; va_copy( VA_List_Target, *va_arg( VA_List_Source, va_list *))
@ -176,6 +272,30 @@ typedef int NDT_Index_Type;
/* Manager Commands */
typedef int NDT_Command;
# define NDD_CMD_UNKNOWN (NDT_Command)0
# define NDD_CMD_MANAGER_VERSION (NDT_Command)1
# define NDD_CMD_INDEX_GET (NDT_Command)2
# define NDD_CMD_VALUE_ALLOC (NDT_Command)3
# define NDD_CMD_VALUE_FREE (NDT_Command)4
# define NDD_CMD_VALUE_COMP (NDT_Command)5
# define NDD_CMD_VALUE_ADD (NDT_Command)6
# define NDD_CMD_VALUE_REMOVE (NDT_Command)7
# define NDD_CMD_VALUE_PRINT (NDT_Command)8
# define NDD_CMD_VALUE_FIND (NDT_Command)9
# define NDD_CMD_INFO_PRINT (NDT_Command)10
# define NDD_CMD_USER_TRAVERSE (NDT_Command)17
typedef char *NDT_Command_Name;
typedef char *NDT_Version_Name;
/* Manager Template */ /* 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) // 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)
@ -511,67 +631,6 @@ typedef int NDT_Index_Type;
/* Manager Commands */
typedef int NDT_Command;
# define NDD_CMD_UNKNOWN (NDT_Command)0
# define NDD_CMD_MANAGER_VERSION (NDT_Command)1
# define NDD_CMD_INDEX_GET (NDT_Command)2
# define NDD_CMD_VALUE_ALLOC (NDT_Command)3
# define NDD_CMD_VALUE_FREE (NDT_Command)4
# define NDD_CMD_VALUE_COMP (NDT_Command)5
# define NDD_CMD_VALUE_ADD (NDT_Command)6
# define NDD_CMD_VALUE_REMOVE (NDT_Command)7
# define NDD_CMD_VALUE_PRINT (NDT_Command)8
# define NDD_CMD_VALUE_FIND (NDT_Command)9
# define NDD_CMD_INFO_PRINT (NDT_Command)10
# define NDD_CMD_USER_TRAVERSE (NDT_Command)17
typedef char *NDT_Command_Name;
typedef char *NDT_Version_Name;
/* Manager or Functions Return Codes */
typedef int NDT_Status;
# define ND_ERROR(s) ( ( s) <= 0) /* All negative or 0 status are errors */
# define NDS_OK 1
# define NDS_KO 0
# define NDS_YES 1
# define NDS_NO 0
# define NDS_EQUAL 1
# define NDS_GREATER 2
# define NDS_LOWER 3
# define NDS_ERRMEM -1 /* Memory allocation problem */
# define NDS_ERRAPI -2 /* Bad API usage */
typedef short NDT_Index_Id;
typedef short NDT_Index_Nb;
# define NDD_INDEX_UNKNOWN (NDT_Index_Id)-1
# define NDD_INDEX_PRIMARY (NDT_Index_Id) 0
/* Predefinition */
typedef struct NDT_Node NDT_Node;
typedef struct NDT_Index NDT_Index;
typedef struct NDT_Root NDT_Root;
/* Manager function pointer */ /* Manager function pointer */
# define NDD_MANAGER_NAME_LEN_MAX 64 # define NDD_MANAGER_NAME_LEN_MAX 64
@ -603,114 +662,101 @@ typedef NDT_Status NDT_Deallocator( void *, NDT_Root *, void *);
/*----------------------------------------------------------------------------*/
typedef struct NDT_Index typedef short NDT_Open_Flag;
{
NDT_Index_Type Type; /* Structure Type (Queue, Stack, Tree, ... ) */
long Node_Number; /* Number of node in the structure */ # define ND_OPEN_FLAG_OPEN 0x0001
long Min_Depth; /* Minimum tree depth */ # define ND_OPEN_FLAG_CREATE 0x0002
long Max_Depth; /* Maximum tree depth */ # define ND_OPEN_FLAG_NEW ~(ND_OPEN_FLAG_OPEN | ND_OPEN_FLAG_CREATE)
long Max_Dif; /* Maximum allowed depth between tree branches before rebalancing */
long Nb_Equ; /* Rebalancing count */
struct NDT_Node *Head; /* Head node */
struct NDT_Node *Tail; /* Tail node */
struct NDT_Node *Save; /* Save pointer (Used by restore function) */
} NDT_Index;
/* Handler definitions */ typedef short NDT_Close_Flag;
# define ND_CLOSE_FLAG_CLOSE 0x0001
# define ND_CLOSE_FLAG_DESTROY 0x0002
typedef short NDT_Lock_Flag;
# define ND_LOCK_FLAG_READ 0x0001
# define ND_LOCK_FLAG_WRITE 0x0002
/*----------------------------------------------------------------------------*/
/* Handler definitions */
/*----------------------------------------------------------------------------*/
typedef short NDT_Handler_Id; typedef short NDT_Handler_Id;
typedef short NDT_Handler_Nb; typedef short NDT_Handler_Nb;
# define NDD_HANDLER_ID_UNKNOWN ( NDT_Handler_Id)-1
# define NDD_HANDLER_ID_MANAGER ( NDT_Handler_Id)0 # define NDD_HANDLER_ID_MANAGER ( NDT_Handler_Id)0
# define NDD_HANDLER_ID_INIT ( NDT_Handler_Id)1 # define NDD_HANDLER_ID_INIT ( NDT_Handler_Id)1
# define NDD_HANDLER_ID_ALLOC ( NDT_Handler_Id)2 # define NDD_HANDLER_ID_ALLOC ( NDT_Handler_Id)2
# define NDD_HANDLER_ID_FREE ( NDT_Handler_Id)3 # define NDD_HANDLER_ID_FREE ( NDT_Handler_Id)3
# define NDD_HANDLER_ID_OPEN ( NDT_Handler_Id)4 # define NDD_HANDLER_ID_OPEN ( NDT_Handler_Id)4
# define NDD_HANDLER_ID_CLOSE ( NDT_Handler_Id)5 # define NDD_HANDLER_ID_CLOSE ( NDT_Handler_Id)5
# define NDD_HANDLER_ID_LOCK ( NDT_Handler_Id)6 # define NDD_HANDLER_ID_INFO ( NDT_Handler_Id)6
# define NDD_HANDLER_ID_UNLOCK ( NDT_Handler_Id)7 # define NDD_HANDLER_ID_LOCK ( NDT_Handler_Id)7
# define NDD_HANDLER_ID_UNLOCK ( NDT_Handler_Id)8
# define NDD_HANDLER_ID_NB ( NDT_Handler_Nb)8 # define NDD_HANDLER_ID_NB ( NDT_Handler_Nb)9
# define NDD_HANDLER_NB NDD_HANDLER_ID_NB # define NDD_HANDLER_NB NDD_HANDLER_ID_NB
# define NDD_HANDLER_NAME_LEN 64 # define NDD_HANDLER_NAME_LEN 64
# define NDD_HANDLER_NAME_SIZE ( NDD_HANDLER_NAME_LEN + 1) # define NDD_HANDLER_NAME_SIZE ( NDD_HANDLER_NAME_LEN + 1)
typedef char *NDT_Handler_Name; typedef char NDT_Handler_Name[ NDD_HANDLER_NAME_SIZE];
typedef NDT_Status (NDT_Handler_Function)( void);
typedef NDT_Status ( NDT_Handler_Function)( void);
typedef NDT_Status NDT_Handler_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Node *Node_Ptr, NDT_Command Cmd, va_list *);
typedef NDT_Status NDT_Handler_Init( size_t *Root_Extra_Size, NDT_Handler *Handler_Tab, void *User_Ptr);
typedef NDT_Status NDT_Handler_Alloc( void **Memory_Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, void *User_Ptr);
typedef NDT_Status NDT_Handler_Free( void *Memory_Ptr, NDT_Root *Root_Ptr, void *User_Ptr);
typedef NDT_Status NDT_Handler_Open( NDT_Root *Root_Ptr, NDT_Open_Flag Open_Mode, void *User_Ptr);
typedef NDT_Status NDT_Handler_Close( NDT_Root *Root_Ptr, NDT_Close_Flag Close_Mode, void *User_Ptr);
typedef NDT_Status NDT_Handler_Info( NDT_Root *Root_Ptr, NDT_Recursive_Offset Recursive_Offset);
typedef NDT_Status NDT_Handler_Lock( NDT_Root *Root_Ptr, NDT_Lock_Flag Lock_Mode, bool *Locked_Ptr, void *User_Ptr);
typedef NDT_Status NDT_Handler_Unlock( NDT_Root *Root_Ptr, void *User_Ptr);
/*----------------------------------------------------------------------------*/
typedef struct NDT_Handler typedef struct NDT_Handler
{ {
NDT_Handler_Name Name[ NDD_MANAGER_NAME_SIZE_MAX]; NDT_Handler_Name Name;
NDT_Handler_Function *Ptr; NDT_Handler_Function *Ptr;
} NDT_Handler; } NDT_Handler;
# define NDD_HANDLER_TAB_SIZE ( sizeof( NDT_Handler) * NDD_HANDLER_NB) # 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); \ # 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); ( 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_ # ifndef _LIBNODE_C_
extern NDT_Handler NDG_Handler_Tab_Default[ NDD_HANDLER_ID_NB]; extern NDT_Handler NDG_Handler_Tab_Default[ NDD_HANDLER_ID_NB];
# endif # endif
/*
RootPtr->Handlers.Manager_Name
*/ /*----------------------------------------------------------------------------*/
/* Root definitions */
/* Root */ /*----------------------------------------------------------------------------*/
# define NDD_DATASTRUCT_NAME_LEN 64 # define NDD_DATASTRUCT_NAME_LEN 64
# define NDD_DATASTRUCT_NAME_SIZE ( NDD_DATASTRUCT_NAME_LEN + 1) # define NDD_DATASTRUCT_NAME_SIZE ( NDD_DATASTRUCT_NAME_LEN + 1)
typedef char *NDT_DataStruct_Name; typedef char *NDT_DataStruct_Name;
@ -772,22 +818,6 @@ typedef struct NDT_Node
typedef int NDT_Recursive_Mode;
typedef int NDT_Recursive_Depth;
typedef int NDT_Recursive_Offset;
# define NDD_RECURSIVE_MODE_UNKNOWN ( NDT_Recursive_Mode)0x00
# define NDD_RECURSIVE_MODE_PARENT ( NDT_Recursive_Mode)0x01
# define NDD_RECURSIVE_MODE_CHILD ( NDT_Recursive_Mode)0x02
# define NDD_RECURSIVE_MODE_PARENT_CHILD ( NDT_Recursive_Mode)0x03
# define ND_RECURSIVE_PARENT_IS(m) ( m & NDD_RECURSIVE_MODE_PARENT)
# define ND_RECURSIVE_CHILD_IS(m) ( m & NDD_RECURSIVE_MODE_CHILD)
# define ND_RECURSIVE_PRINT_OFFSET 8
/* Alias API definition */ /* Alias API definition */
# ifndef ND_MODE # ifndef ND_MODE
@ -843,6 +873,15 @@ typedef int NDT_Recursive_Offset;
# define ND_Manager_Exec ND_Manager_Exec_I # define ND_Manager_Exec ND_Manager_Exec_I
# define ND_Alloc ND_Alloc_I # define ND_Alloc ND_Alloc_I
# define ND_Free ND_Free_I # define ND_Free ND_Free_I
# define ND_Handler_Init_Exec ND_Handler_Init_Exec_I
# define ND_Handler_Alloc_Exec ND_Handler_Alloc_Exec_I
# define ND_Handler_Free_Exec ND_Handler_Free_Exec_I
# define ND_Handler_Open_Exec ND_Handler_Open_Exec_I
# define ND_Handler_Close_Exec ND_Handler_Close_Exec_I
# define ND_Handler_Info_Exec ND_Handler_Info_Exec_I
# define ND_Handler_Lock_Exec ND_Handler_Lock_Exec_I
# define ND_Handler_Unlock_Exec ND_Handler_Unlock_Exec_I
# define ND_Allocator_Exec ND_Allocator_Exec_I # define ND_Allocator_Exec ND_Allocator_Exec_I
# define ND_Deallocator_Exec ND_Deallocator_Exec_I # define ND_Deallocator_Exec ND_Deallocator_Exec_I
@ -899,6 +938,15 @@ typedef int NDT_Recursive_Offset;
# define ND_Manager_Exec ND_Manager_Exec_C # define ND_Manager_Exec ND_Manager_Exec_C
# define ND_Alloc ND_Alloc_C # define ND_Alloc ND_Alloc_C
# define ND_Free ND_Free_C # define ND_Free ND_Free_C
# define ND_Handler_Init_Exec ND_Handler_Init_Exec_C
# define ND_Handler_Alloc_Exec ND_Handler_Alloc_Exec_C
# define ND_Handler_Free_Exec ND_Handler_Free_Exec_C
# define ND_Handler_Open_Exec ND_Handler_Open_Exec_C
# define ND_Handler_Close_Exec ND_Handler_Close_Exec_C
# define ND_Handler_Info_Exec ND_Handler_Info_Exec_C
# define ND_Handler_Lock_Exec ND_Handler_Lock_Exec_C
# define ND_Handler_Unlock_Exec ND_Handler_Unlock_Exec_C
# define ND_Allocator_Exec ND_Allocator_Exec_C # define ND_Allocator_Exec ND_Allocator_Exec_C
# define ND_Deallocator_Exec ND_Deallocator_Exec_C # define ND_Deallocator_Exec ND_Deallocator_Exec_C
@ -1445,13 +1493,125 @@ NDD_DLL_API NDT_Status ND_Free_C( void *, NDT_Root *, void *);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Initialize an handlers struture to default value */ /* Execute an init handler function */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* (I) Handlers_Ptr: Handlers pointer to be initialized */ /* (O) Root_Extra_Size: Pointer on the extra root size */
/* (I) Handler_Tab: Pointer on the handler tab */
/* (I) Handler_Init_Name: Init handler function name */
/* (I) Handler_Init_Ptr: Init handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
NDD_DLL_API NDT_Status ND_Handlers_Init_I( NDT_Handler *Handlers_Tab); NDT_Status ND_Handler_Init_Exec_I( size_t *Root_Extra_Size, NDT_Handler *Handler_Tab, NDT_Handler_Name Handler_Init_Name, NDT_Handler_Init *Handler_Init_Ptr, void *User_Ptr);
NDD_DLL_API NDT_Status ND_Handlers_Init_C( NDT_Handler *Handlers_Tab); NDT_Status ND_Handler_Init_Exec_C( size_t *Root_Extra_Size, NDT_Handler *Handler_Tab, NDT_Handler_Name Handler_Init_Name, NDT_Handler_Init *Handler_Init_Ptr, void *User_Ptr);
/*----------------------------------------------------------------------------*/
/* Execute an alloc handler function */
/*----------------------------------------------------------------------------*/
/* (O) Memory_Ptr_Ptr: Memory pointer address */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Size: Allocation size */
/* (I) Handler_Alloc_Name: Alloc handler function name */
/* (I) Handler_Alloc_Ptr: Alloc handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Alloc_Exec_I( void **Memory_Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, NDT_Handler_Name Handler_Alloc_Name, NDT_Handler_Alloc *Handler_Alloc_Ptr, void *User_Ptr);
NDT_Status ND_Handler_Alloc_Exec_C( void **Memory_Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, NDT_Handler_Name Handler_Alloc_Name, NDT_Handler_Alloc *Handler_Alloc_Ptr, void *User_Ptr);
/*----------------------------------------------------------------------------*/
/* Execute a free handler function */
/*----------------------------------------------------------------------------*/
/* (I) Memory_Ptr: Memory pointer */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Handler_Free_Name: Free handler function name */
/* (I) Handler_Free_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Free_Exec_I( void *Memory_Ptr, NDT_Root *Root_Ptr, NDT_Handler_Name Handler_Free_Name, NDT_Handler_Free *Handler_Free_Ptr, void *User_Ptr);
NDT_Status ND_Handler_Free_Exec_C( void *Memory_Ptr, NDT_Root *Root_Ptr, NDT_Handler_Name Handler_Free_Name, NDT_Handler_Free *Handler_Free_Ptr, void *User_Ptr);
/*----------------------------------------------------------------------------*/
/* Execute an open handler function */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Open_Mode: Open mode */
/* (I) Handler_Open_Name: Free handler function name */
/* (I) Handler_Open_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Open_Exec_I( NDT_Root *Root_Ptr, NDT_Open_Flag Open_Mode, NDT_Handler_Name Handler_Open_Name, NDT_Handler_Open *Handler_Open_Ptr, void *User_Ptr);
NDT_Status ND_Handler_Open_Exec_C( NDT_Root *Root_Ptr, NDT_Open_Flag Open_Mode, NDT_Handler_Name Handler_Open_Name, NDT_Handler_Open *Handler_Open_Ptr, void *User_Ptr);
/*----------------------------------------------------------------------------*/
/* Execute a close handler function */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Close_Mode: Close mode */
/* (I) Handler_Close_Name: Free handler function name */
/* (I) Handler_Close_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Close_Exec_I( NDT_Root *Root_Ptr, NDT_Close_Flag Close_Mode, NDT_Handler_Name Handler_Close_Name, NDT_Handler_Close *Handler_Close_Ptr, void *User_Ptr);
NDT_Status ND_Handler_Close_Exec_C( NDT_Root *Root_Ptr, NDT_Close_Flag Close_Mode, NDT_Handler_Name Handler_Close_Name, NDT_Handler_Close *Handler_Close_Ptr, void *User_Ptr);
/*----------------------------------------------------------------------------*/
/* Execute an Info handler function */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Recursive_Offset: Print line offset */
/* (I) Handler_Info_Name: Free handler function name */
/* (I) Handler_Info_Ptr: Free handler function pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Info_Exec_I( NDT_Root *Root_Ptr, NDT_Recursive_Offset Recursive_Offset, NDT_Handler_Name Handler_Info_Name, NDT_Handler_Info *Handler_Info_Ptr);
NDT_Status ND_Handler_Info_Exec_C( NDT_Root *Root_Ptr, NDT_Recursive_Offset Recursive_Offset, NDT_Handler_Name Handler_Info_Name, NDT_Handler_Info *Handler_Info_Ptr);
/*----------------------------------------------------------------------------*/
/* Execute a lock handler function */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Open_Mode: Lock mode */
/* (O) Locked_Ptr: Locked flag */
/* (I) Handler_Lock_Name: Free handler function name */
/* (I) Handler_Lock_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Lock_Exec_I( NDT_Root *Root_Ptr, NDT_Lock_Flag Lock_Mode, bool *Locked_Ptr, NDT_Handler_Name Handler_Lock_Name, NDT_Handler_Lock *Handler_Lock_Ptr, void *User_Ptr);
NDT_Status ND_Handler_Lock_Exec_C( NDT_Root *Root_Ptr, NDT_Lock_Flag Lock_Mode, bool *Locked_Ptr, NDT_Handler_Name Handler_Lock_Name, NDT_Handler_Lock *Handler_Lock_Ptr, void *User_Ptr);
/*----------------------------------------------------------------------------*/
/* Execute an unlock handler function */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Handler_Unlock_Name: Free handler function name */
/* (I) Handler_Unlock_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Unlock_Exec_I( NDT_Root *Root_Ptr, NDT_Handler_Name Handler_Unlock_Name, NDT_Handler_Unlock *Handler_Unlock_Ptr, void *User_Ptr);
NDT_Status ND_Handler_Unlock_Exec_C( NDT_Root *Root_Ptr, NDT_Handler_Name Handler_Unlock_Name, NDT_Handler_Unlock *Handler_Unlock_Ptr, void *User_Ptr);
@ -1465,7 +1625,7 @@ NDD_DLL_API NDT_Status ND_Handlers_Init_C( NDT_Handler *Handlers_Tab);
/* (I) Allocator_Ptr: Value allocator function pointer */ /* (I) Allocator_Ptr: Value allocator function pointer */
/* (I) Data_Ptr: User pointer */ /* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* to be deleted */
NDD_DLL_API NDT_Status ND_Allocator_Exec_I( void **, NDT_Root *, size_t, NDT_Allocator_Name, NDT_Allocator *, void *); NDD_DLL_API NDT_Status ND_Allocator_Exec_I( void **, NDT_Root *, size_t, NDT_Allocator_Name, NDT_Allocator *, void *);
NDD_DLL_API NDT_Status ND_Allocator_Exec_C( void **, NDT_Root *, size_t, NDT_Allocator_Name, NDT_Allocator *, void *); NDD_DLL_API NDT_Status ND_Allocator_Exec_C( void **, NDT_Root *, size_t, NDT_Allocator_Name, NDT_Allocator *, void *);
@ -1480,7 +1640,7 @@ NDD_DLL_API NDT_Status ND_Allocator_Exec_C( void **, NDT_Root *, size_t, NDT_
/* (I) Allocator_Ptr: Value deallocator function pointer */ /* (I) Allocator_Ptr: Value deallocator function pointer */
/* (I) Data_Ptr: User pointer */ /* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* to be deleted */
NDD_DLL_API NDT_Status ND_Deallocator_Exec_I( void *, NDT_Root *, NDT_Deallocator_Name, NDT_Deallocator *, void *); NDD_DLL_API NDT_Status ND_Deallocator_Exec_I( void *, NDT_Root *, NDT_Deallocator_Name, NDT_Deallocator *, void *);
NDD_DLL_API NDT_Status ND_Deallocator_Exec_C( void *, NDT_Root *, NDT_Deallocator_Name, NDT_Deallocator *, void *); NDD_DLL_API NDT_Status ND_Deallocator_Exec_C( void *, NDT_Root *, NDT_Deallocator_Name, NDT_Deallocator *, void *);

View File

@ -973,11 +973,12 @@ 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_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_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_Tab, short Own_Value, void *Data_Ptr) NDT_Handler *Handler_Tab, short Own_Value, void *User_Ptr)
{ {
NDT_Status status; NDT_Status status;
NDT_Handler handler_target_tab[ NDD_HANDLER_NB]; NDT_Handler handler_target_tab[ NDD_HANDLER_NB];
NDT_Handler_Id handler_id; NDT_Handler_Id handler_id;
size_t root_extra_size;
if( Handler_Tab == NULL) if( Handler_Tab == NULL)
@ -993,26 +994,24 @@ NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_DataStruct_Name
if( Manager_Name != NULL) if( Manager_Name != NULL)
{ {
NDD_HANDLER_SET( handler_target_tab[ NDD_HANDLER_ID_MANAGER], Manager_Name, 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 else
{ {
if( Manager_Ptr != NULL) if( Manager_Ptr != NULL)
{ {
NDD_HANDLER_SET( handler_target_tab[ NDD_HANDLER_ID_MANAGER], "", 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;
} }
} }
/* Call init function */ /* Call init function */
if( ( status = ND_Handler_Init_Exec_I( &root_extra_size, handler_target_tab, handler_target_tab[ NDD_HANDLER_ID_INIT].Name, ( NDT_Handler_Init *)handler_target_tab[ NDD_HANDLER_ID_INIT].Ptr, User_Ptr)) != NDS_OK)
{
return( status);
}
/* Complete with default handlers */ /* Complete with default handlers */
for( handler_id = 0; handler_id < NDD_HANDLER_ID_NB; handler_id++) for( handler_id = 0; handler_id < NDD_HANDLER_ID_NB; handler_id++)
@ -1023,42 +1022,21 @@ NDT_Status ND_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, NDT_DataStruct_Name
} }
} }
/*
NDG_Handler_Tab_Default[ handler_id]
if( ( strlen( handlers_target.Manager_Name) == 0) && ( handlers_target.Manager_Ptr == NULL)) if( ( status = ND_Node_Root_Alloc( Root_Ptr_Ptr, Name, Index_Nb, Type_Ptr, handler_target_tab, root_extra_size, Own_Value, User_Ptr)) != NDS_OK)
{ {
return( status);
// 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))
/* Call init function */
if( ( status = ND_Handler_Open_Exec_I( *Root_Ptr_Ptr, 0, handler_target_tab[ NDD_HANDLER_ID_OPEN].Name, ( NDT_Handler_Open *)handler_target_tab[ NDD_HANDLER_ID_OPEN].Ptr, User_Ptr)) != NDS_OK)
{ {
ND_STRCPY( handlers_target.Alloc_Name, "ND_Default_Allocator", NDD_HANDLER_NAME_SIZE); return( status);
handlers_target.Alloc_Ptr = ND_Default_Allocator;
} }
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, handler_target_tab, Own_Value, Data_Ptr);
if( ND_ERROR( status)) return( status);
return( NDS_OK); return( NDS_OK);
} }
@ -2153,10 +2131,12 @@ NDT_Status ND_DataStruct_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Recu
if( ND_RECURSIVE_PARENT_IS( Recursive_Mode)) if( ND_RECURSIVE_PARENT_IS( Recursive_Mode))
{ {
memset( offset, ' ', Recursive_Offset * ND_RECURSIVE_PRINT_OFFSET); memset( offset, ' ', Recursive_Offset * ND_RECURSIVE_PRINT_OFFSET);
offset[Recursive_Offset * ND_RECURSIVE_PRINT_OFFSET] = '\0'; offset[ Recursive_Offset * ND_RECURSIVE_PRINT_OFFSET] = '\0';
status = ND_Manager_Exec_I( Root_Ptr, NDD_INDEX_UNKNOWN, NULL, NDD_CMD_MANAGER_VERSION, &version_name); if( ( status = ND_Manager_Exec_I( Root_Ptr, NDD_INDEX_UNKNOWN, NULL, NDD_CMD_MANAGER_VERSION, &version_name)) != NDS_OK)
if( ND_ERROR( status)) return( status); {
return( status);
}
/* /*
fprintf( Out, "%sRoot: (%s%p)\tIndex Nb: (%d)\tIndex Open Count: (%d)\tManager: (%s%p) [%s]\n%sAllocator: (%s%p) [%s]\tDeallocator: (%s%p) [%s]\tUser: (%s%p)\n%sManager Version: [%s]\n\n", fprintf( Out, "%sRoot: (%s%p)\tIndex Nb: (%d)\tIndex Open Count: (%d)\tManager: (%s%p) [%s]\n%sAllocator: (%s%p) [%s]\tDeallocator: (%s%p) [%s]\tUser: (%s%p)\n%sManager Version: [%s]\n\n",
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, 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,
@ -2164,8 +2144,8 @@ NDT_Status ND_DataStruct_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Recu
offset, version_name); offset, version_name);
*/ */
LG_LOG_INFO_6( "%sRoot: (%s%p)\tName: [%s]\tIndex Nb: (%d)\tIndex Open Count: (%d)", LG_LOG_INFO_7( "%sRoot: (%s%p)\tName: [%s]\tIndex Nb: (%d)\tIndex Open Count: (%d)\tRoot_Size: (%ld)",
offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr, Root_Ptr->Name, Root_Ptr->Index_Nb, Root_Ptr->Index_Open_Count); offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr, Root_Ptr->Name, Root_Ptr->Index_Nb, Root_Ptr->Index_Open_Count, Root_Ptr->Root_Size);
LG_LOG_INFO_13( "%sManager: (%s%p) [%s]\tInit: (%s%p) [%s]\tAlloc: (%s%p) [%s]\tFree: (%s%p) [%s]", offset, 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_MANAGER].Ptr, Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_MANAGER].Name,
@ -2182,6 +2162,11 @@ NDT_Status ND_DataStruct_Info_Print_I( FILE *Out, NDT_Root *Root_Ptr, NDT_Recu
LG_LOG_INFO_4( "%sUser: (%s%p)\tManager Version: [%s]", LG_LOG_INFO_4( "%sUser: (%s%p)\tManager Version: [%s]",
offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr->User_Ptr, version_name); offset, NDD_PRINTF_PTR_PREFIX, Root_Ptr->User_Ptr, version_name);
if( ( status = ND_Handler_Info_Exec_I( Root_Ptr, Recursive_Offset, Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_INFO].Name, ( NDT_Handler_Info *)Root_Ptr->Handler_Tab[ NDD_HANDLER_ID_INFO].Ptr)) != NDS_OK)
{
return( status);
}
LG_LOG_INFO_0( ""); LG_LOG_INFO_0( "");
} }
@ -3639,50 +3624,399 @@ NDT_Status ND_Manager_Exec_C( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Initialize an handlers struture to default value */ /* Execute an init handler function */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* (I) Handlers_Ptr: Handlers pointer to be initialized */ /* (O) Root_Extra_Size: Pointer on the extra root size */
/* (I) Handler_Tab: Pointer on the handler tab */
/* (I) Handler_Init_Name: Init handler function name */
/* (I) Handler_Init_Ptr: Init handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
NDT_Status ND_Handlers_Init_I( NDT_Handler *Handler_Tab) NDT_Status ND_Handler_Init_Exec_I( size_t *Root_Extra_Size, NDT_Handler *Handler_Tab, NDT_Handler_Name Handler_Init_Name, NDT_Handler_Init *Handler_Init_Ptr, void *User_Ptr)
{ {
} NDT_Handler_Init *handler_init_ptr;
if( Handler_Init_Ptr != NULL)
/*----------------------------------------------------------------------------*/
/* 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; handler_init_ptr = Handler_Init_Ptr;
} }
else else
{ {
if( ND_Symbol_Find( (void **)&allocator_ptr, Allocator_Name) != NDS_OK) if( ND_Symbol_Find( (void **)&handler_init_ptr, Handler_Init_Name) != NDS_OK)
{ {
LG_LOG_ERROR_0( "Cant't find allocator function"); LG_LOG_ERROR_0( "Cant't find init handler function");
return( NDS_KO); return( NDS_KO);
} }
} }
return( allocator_ptr( Ptr_Ptr, Root_Ptr, Size, Data_Ptr)); return( handler_init_ptr( Root_Extra_Size, Handler_Tab, User_Ptr));
}
/*----------------------------------------------------------------------------*/
/* Execute an init handler function */
/*----------------------------------------------------------------------------*/
/* (O) Root_Extra_Size: Pointer on the extra root size */
/* (I) Handler_Tab: Pointer on the handler tab */
/* (I) Handler_Init_Name: Init handler function name */
/* (I) Handler_Init_Ptr: Init handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Init_Exec_C( size_t *Root_Extra_Size, NDT_Handler *Handler_Tab, NDT_Handler_Name Handler_Init_Name, NDT_Handler_Init *Handler_Init_Ptr, void *User_Ptr)
{
ND_LIBNODE_OPEN_CHECK();
ND_HANDLER_NOT_NULL_CHECK( Handler_Init_Name, Handler_Init_Ptr);
return( ND_Handler_Init_Exec_I( Root_Extra_Size, Handler_Tab, Handler_Init_Name, Handler_Init_Ptr, User_Ptr));
}
/*----------------------------------------------------------------------------*/
/* Execute an alloc handler function */
/*----------------------------------------------------------------------------*/
/* (O) Memory_Ptr_Ptr: Memory pointer address */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Size: Allocation size */
/* (I) Handler_Alloc_Name: Alloc handler function name */
/* (I) Handler_Alloc_Ptr: Alloc handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Alloc_Exec_I( void **Memory_Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, NDT_Handler_Name Handler_Alloc_Name, NDT_Handler_Alloc *Handler_Alloc_Ptr, void *User_Ptr)
{
NDT_Handler_Alloc *handler_alloc_ptr;
if( Handler_Alloc_Ptr != NULL)
{
handler_alloc_ptr = Handler_Alloc_Ptr;
}
else
{
if( ND_Symbol_Find( (void **)&handler_alloc_ptr, Handler_Alloc_Name) != NDS_OK)
{
LG_LOG_ERROR_0( "Cant't find alloc handler function");
return( NDS_KO);
}
}
return( handler_alloc_ptr( Memory_Ptr_Ptr, Root_Ptr, Size, User_Ptr));
}
/*----------------------------------------------------------------------------*/
/* Execute an alloc handler function */
/*----------------------------------------------------------------------------*/
/* (O) Memory_Ptr_Ptr: Memory pointer address */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Size: Allocation size */
/* (I) Handler_Alloc_Name: Alloc handler function name */
/* (I) Handler_Alloc_Ptr: Alloc handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Alloc_Exec_C( void **Memory_Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, NDT_Handler_Name Handler_Alloc_Name, NDT_Handler_Alloc *Handler_Alloc_Ptr, void *User_Ptr)
{
ND_LIBNODE_OPEN_CHECK();
ND_HANDLER_NOT_NULL_CHECK( Handler_Alloc_Name, Handler_Alloc_Ptr);
return( ND_Handler_Alloc_Exec_I( Memory_Ptr_Ptr, Root_Ptr, Size, Handler_Alloc_Name, Handler_Alloc_Ptr, User_Ptr));
}
/*----------------------------------------------------------------------------*/
/* Execute a free handler function */
/*----------------------------------------------------------------------------*/
/* (I) Memory_Ptr: Memory pointer */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Handler_Free_Name: Free handler function name */
/* (I) Handler_Free_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Free_Exec_I( void *Memory_Ptr, NDT_Root *Root_Ptr, NDT_Handler_Name Handler_Free_Name, NDT_Handler_Free *Handler_Free_Ptr, void *User_Ptr)
{
NDT_Handler_Free *handler_free_ptr;
ND_HANDLER_SYMBOL_FIND( handler_free_ptr, Handler_Free_Name, Handler_Free_Ptr);
return( handler_free_ptr( Memory_Ptr, Root_Ptr, User_Ptr));
}
/*----------------------------------------------------------------------------*/
/* Execute a free handler function */
/*----------------------------------------------------------------------------*/
/* (I) Memory_Ptr: Memory pointer */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Handler_Free_Name: Free handler function name */
/* (I) Handler_Free_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Free_Exec_C( void *Memory_Ptr, NDT_Root *Root_Ptr, NDT_Handler_Name Handler_Free_Name, NDT_Handler_Free *Handler_Free_Ptr, void *User_Ptr)
{
ND_LIBNODE_OPEN_CHECK();
ND_HANDLER_NOT_NULL_CHECK( Handler_Free_Name, Handler_Free_Ptr);
return( ND_Handler_Free_Exec_I( Memory_Ptr, Root_Ptr, Handler_Free_Name, Handler_Free_Ptr, User_Ptr));
}
/*----------------------------------------------------------------------------*/
/* Execute an open handler function */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Open_Mode: Open mode */
/* (I) Handler_Open_Name: Free handler function name */
/* (I) Handler_Open_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Open_Exec_I( NDT_Root *Root_Ptr, NDT_Open_Flag Open_Mode, NDT_Handler_Name Handler_Open_Name, NDT_Handler_Open *Handler_Open_Ptr, void *User_Ptr)
{
NDT_Handler_Open *handler_open_ptr;
ND_HANDLER_SYMBOL_FIND( handler_open_ptr, Handler_Open_Name, Handler_Open_Ptr);
return( handler_open_ptr( Root_Ptr, Open_Mode, User_Ptr));
}
/*----------------------------------------------------------------------------*/
/* Execute an open handler function */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Open_Mode: Open mode */
/* (I) Handler_Open_Name: Free handler function name */
/* (I) Handler_Open_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Open_Exec_C( NDT_Root *Root_Ptr, NDT_Open_Flag Open_Mode, NDT_Handler_Name Handler_Open_Name, NDT_Handler_Open *Handler_Open_Ptr, void *User_Ptr)
{
ND_LIBNODE_OPEN_CHECK();
ND_HANDLER_NOT_NULL_CHECK( Handler_Open_Name, Handler_Open_Ptr);
return( ND_Handler_Open_Exec_I( Root_Ptr, Open_Mode, Handler_Open_Name, Handler_Open_Ptr, User_Ptr));
}
/*----------------------------------------------------------------------------*/
/* Execute a close handler function */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Close_Mode: Close mode */
/* (I) Handler_Close_Name: Free handler function name */
/* (I) Handler_Close_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Close_Exec_I( NDT_Root *Root_Ptr, NDT_Close_Flag Close_Mode, NDT_Handler_Name Handler_Close_Name, NDT_Handler_Close *Handler_Close_Ptr, void *User_Ptr)
{
NDT_Handler_Close *handler_close_ptr;
ND_HANDLER_SYMBOL_FIND( handler_close_ptr, Handler_Close_Name, Handler_Close_Ptr);
return( handler_close_ptr( Root_Ptr, Close_Mode, User_Ptr));
}
/*----------------------------------------------------------------------------*/
/* Execute a close handler function */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Close_Mode: Close mode */
/* (I) Handler_Close_Name: Free handler function name */
/* (I) Handler_Close_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Close_Exec_C( NDT_Root *Root_Ptr, NDT_Close_Flag Close_Mode, NDT_Handler_Name Handler_Close_Name, NDT_Handler_Close *Handler_Close_Ptr, void *User_Ptr)
{
ND_LIBNODE_OPEN_CHECK();
ND_HANDLER_NOT_NULL_CHECK( Handler_Close_Name, Handler_Close_Ptr);
return( ND_Handler_Close_Exec_I( Root_Ptr, Close_Mode, Handler_Close_Name, Handler_Close_Ptr, User_Ptr));
}
/*----------------------------------------------------------------------------*/
/* Execute an Info handler function */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Recursive_Offset: Print line offset */
/* (I) Handler_Info_Name: Free handler function name */
/* (I) Handler_Info_Ptr: Free handler function pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Info_Exec_I( NDT_Root *Root_Ptr, NDT_Recursive_Offset Recursive_Offset, NDT_Handler_Name Handler_Info_Name, NDT_Handler_Info *Handler_Info_Ptr)
{
NDT_Handler_Info *handler_info_ptr;
ND_HANDLER_SYMBOL_FIND( handler_info_ptr, Handler_Info_Name, Handler_Info_Ptr);
return( handler_info_ptr( Root_Ptr, Recursive_Offset));
}
/*----------------------------------------------------------------------------*/
/* Execute an Info handler function */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Recursive_Offset: Print line offset */
/* (I) Handler_Info_Name: Free handler function name */
/* (I) Handler_Info_Ptr: Free handler function pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Info_Exec_C( NDT_Root *Root_Ptr, NDT_Recursive_Offset Recursive_Offset, NDT_Handler_Name Handler_Info_Name, NDT_Handler_Info *Handler_Info_Ptr)
{
ND_LIBNODE_OPEN_CHECK();
ND_HANDLER_NOT_NULL_CHECK( Handler_Info_Name, Handler_Info_Ptr);
return( ND_Handler_Info_Exec_I( Root_Ptr, Recursive_Offset, Handler_Info_Name, Handler_Info_Ptr));
}
/*----------------------------------------------------------------------------*/
/* Execute a lock handler function */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Open_Mode: Lock mode */
/* (O) Locked_Ptr: Locked flag */
/* (I) Handler_Lock_Name: Free handler function name */
/* (I) Handler_Lock_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Lock_Exec_I( NDT_Root *Root_Ptr, NDT_Lock_Flag Lock_Mode, bool *Locked_Ptr, NDT_Handler_Name Handler_Lock_Name, NDT_Handler_Lock *Handler_Lock_Ptr, void *User_Ptr)
{
NDT_Handler_Lock *handler_lock_ptr;
ND_HANDLER_SYMBOL_FIND( handler_lock_ptr, Handler_Lock_Name, Handler_Lock_Ptr);
return( handler_lock_ptr( Root_Ptr, Lock_Mode, Locked_Ptr, User_Ptr));
}
/*----------------------------------------------------------------------------*/
/* Execute a lock handler function */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Open_Mode: Lock mode */
/* (O) Locked_Ptr: Locked flag */
/* (I) Handler_Lock_Name: Free handler function name */
/* (I) Handler_Lock_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Lock_Exec_C( NDT_Root *Root_Ptr, NDT_Lock_Flag Lock_Mode, bool *Locked_Ptr, NDT_Handler_Name Handler_Lock_Name, NDT_Handler_Lock *Handler_Lock_Ptr, void *User_Ptr)
{
ND_LIBNODE_OPEN_CHECK();
ND_HANDLER_NOT_NULL_CHECK( Handler_Lock_Name, Handler_Lock_Ptr);
return( ND_Handler_Lock_Exec_I( Root_Ptr, Lock_Mode, Locked_Ptr, Handler_Lock_Name, Handler_Lock_Ptr, User_Ptr));
}
/*----------------------------------------------------------------------------*/
/* Execute an unlock handler function */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Handler_Unlock_Name: Free handler function name */
/* (I) Handler_Unlock_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Unlock_Exec_I( NDT_Root *Root_Ptr, NDT_Handler_Name Handler_Unlock_Name, NDT_Handler_Unlock *Handler_Unlock_Ptr, void *User_Ptr)
{
NDT_Handler_Unlock *handler_unlock_ptr;
ND_HANDLER_SYMBOL_FIND( handler_unlock_ptr, Handler_Unlock_Name, Handler_Unlock_Ptr);
return( handler_unlock_ptr( Root_Ptr, User_Ptr));
}
/*----------------------------------------------------------------------------*/
/* Execute an unlock handler function */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Handler_Unlock_Name: Free handler function name */
/* (I) Handler_Unlock_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Unlock_Exec_C( NDT_Root *Root_Ptr, NDT_Handler_Name Handler_Unlock_Name, NDT_Handler_Unlock *Handler_Unlock_Ptr, void *User_Ptr)
{
ND_LIBNODE_OPEN_CHECK();
ND_HANDLER_NOT_NULL_CHECK( Handler_Unlock_Name, Handler_Unlock_Ptr);
return( ND_Handler_Unlock_Exec_I( Root_Ptr, Handler_Unlock_Name, Handler_Unlock_Ptr, User_Ptr));
} }
@ -3699,7 +4033,7 @@ NDT_Status ND_Handler_Init_Exec_I( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t
/* (I) Allocator_Ptr: Value allocator function pointer */ /* (I) Allocator_Ptr: Value allocator function pointer */
/* (I) Data_Ptr: User pointer */ /* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* to be deleted */
NDT_Status ND_Allocator_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_Status ND_Allocator_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; NDT_Allocator *allocator_ptr;
@ -3736,17 +4070,12 @@ NDT_Status ND_Allocator_Exec_I( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t S
/* (I) Allocator_Ptr: Value allocator function pointer */ /* (I) Allocator_Ptr: Value allocator function pointer */
/* (I) Data_Ptr: User pointer */ /* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* to be deleted */
NDT_Status ND_Allocator_Exec_C( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, NDT_Allocator_Name Allocator_Name, NDT_Allocator *Allocator_Ptr, void *Data_Ptr) NDT_Status ND_Allocator_Exec_C( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, NDT_Allocator_Name Allocator_Name, NDT_Allocator *Allocator_Ptr, void *Data_Ptr)
{ {
ND_LIBNODE_OPEN_CHECK(); ND_LIBNODE_OPEN_CHECK();
if( ( Allocator_Name == NULL) && ( Allocator_Ptr == NULL)) ND_HANDLER_NOT_NULL_CHECK( Allocator_Name, Allocator_Ptr);
{
LG_LOG_ERROR_0( "Undefined function name");
return( NDS_ERRAPI);
}
return( ND_Allocator_Exec_I( Ptr_Ptr, Root_Ptr, Size, Allocator_Name, Allocator_Ptr, Data_Ptr)); return( ND_Allocator_Exec_I( Ptr_Ptr, Root_Ptr, Size, Allocator_Name, Allocator_Ptr, Data_Ptr));
} }
@ -3764,7 +4093,7 @@ NDT_Status ND_Allocator_Exec_C( void **Ptr_Ptr, NDT_Root *Root_Ptr, size_t S
/* (I) Allocator_Ptr: Value deallocator function pointer */ /* (I) Allocator_Ptr: Value deallocator function pointer */
/* (I) Data_Ptr: User pointer */ /* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* to be deleted */
NDT_Status ND_Deallocator_Exec_I( void *Ptr, NDT_Root *Root_Ptr, NDT_Deallocator_Name Deallocator_Name, NDT_Deallocator *Deallocator_Ptr, void *Data_Ptr) NDT_Status ND_Deallocator_Exec_I( void *Ptr, NDT_Root *Root_Ptr, NDT_Deallocator_Name Deallocator_Name, NDT_Deallocator *Deallocator_Ptr, void *Data_Ptr)
{ {
NDT_Deallocator *deallocator_ptr; NDT_Deallocator *deallocator_ptr;
@ -3800,7 +4129,7 @@ NDT_Status ND_Deallocator_Exec_I( void *Ptr, NDT_Root *Root_Ptr, NDT_Deallocat
/* (I) Allocator_Ptr: Value deallocator function pointer */ /* (I) Allocator_Ptr: Value deallocator function pointer */
/* (I) Data_Ptr: User pointer */ /* (I) Data_Ptr: User pointer */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* to be deleted */
NDT_Status ND_Deallocator_Exec_C( void *Ptr, NDT_Root *Root_Ptr, NDT_Deallocator_Name Deallocator_Name, NDT_Deallocator *Deallocator_Ptr, void *Data_Ptr) NDT_Status ND_Deallocator_Exec_C( void *Ptr, NDT_Root *Root_Ptr, NDT_Deallocator_Name Deallocator_Name, NDT_Deallocator *Deallocator_Ptr, void *Data_Ptr)
{ {
ND_LIBNODE_OPEN_CHECK(); ND_LIBNODE_OPEN_CHECK();
@ -3827,6 +4156,164 @@ NDT_Status ND_Deallocator_Exec_C( void *Ptr, NDT_Root *Root_Ptr, NDT_Deallocat
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Init handler: */
/* - Return extra root size */
/* - Update handler tab */
/*----------------------------------------------------------------------------*/
/* (O) Root_Extra_Size: Pointer on the extra root size */
/* (I) Handler_Tab: Pointer on the handler tab */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Init_Default( size_t *Root_Extra_Size, NDT_Handler *Handler_Tab, void *User_Ptr)
{
*Root_Extra_Size = 0L;
return( NDS_OK);
}
/*----------------------------------------------------------------------------*/
/* Default alloc handler: */
/* malloc() function wrapper with NDT_Status return status */
/*----------------------------------------------------------------------------*/
/* (O) Memory_Ptr_Ptr: Memory pointer address */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Size: Allocation size */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Alloc_Default( void **Memory_Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, void *User_Ptr)
{
*Memory_Ptr_Ptr = malloc( Size);
if( !*Memory_Ptr_Ptr) return( NDS_ERRMEM);
return( NDS_OK);
}
/*----------------------------------------------------------------------------*/
/* Default free handler: */
/* free() function wrapper with NDT_Status return status */
/*----------------------------------------------------------------------------*/
/* (I) Memory_Ptr: Memory pointer */
/* (I) Root_Ptr: Data structure pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Free_Default( void *Memory_Ptr, NDT_Root *Root_Ptr, void *User_Ptr)
{
if( !Memory_Ptr) return( NDS_ERRAPI);
free( Memory_Ptr);
return( NDS_OK);
}
/*----------------------------------------------------------------------------*/
/* Default open handler */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Open_Mode: Open mode */
/* (I) Handler_Open_Name: Free handler function name */
/* (I) Handler_Open_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Open_Default( NDT_Root *Root_Ptr, NDT_Open_Flag Open_Mode, void *User_Ptr)
{
return( NDS_OK);
}
/*----------------------------------------------------------------------------*/
/* Default close handler */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Close_Mode: Close mode */
/* (I) Handler_Close_Name: Free handler function name */
/* (I) Handler_Close_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Close_Default( NDT_Root *Root_Ptr, NDT_Close_Flag Close_Mode, void *User_Ptr)
{
return( NDS_OK);
}
/*----------------------------------------------------------------------------*/
/* Default info handler */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Recursive_Offset: Print line offset */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Info_Default( NDT_Root *Root_Ptr, NDT_Recursive_Offset Recursive_Offset)
{
return( NDS_OK);
}
/*----------------------------------------------------------------------------*/
/* Default lock handler */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Open_Mode: Lock mode */
/* (O) Locked_Ptr: Locked flag */
/* (I) Handler_Lock_Name: Free handler function name */
/* (I) Handler_Lock_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Lock_Default( NDT_Root *Root_Ptr, NDT_Lock_Flag Lock_Mode, bool *Locked_Ptr, void *User_Ptr)
{
return( NDS_OK);
}
/*----------------------------------------------------------------------------*/
/* Defalt unlock handler */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Handler_Unlock_Name: Free handler function name */
/* (I) Handler_Unlock_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Unlock_Default( NDT_Root *Root_Ptr, void *User_Ptr)
{
return( NDS_OK);
}
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* Symbol Lookup */ /* Symbol Lookup */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
@ -3977,19 +4464,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_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_Handler *Handler_Tab, 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, size_t Root_Extra_Size, short Own_Value, void *User_Ptr)
{ {
NDT_Status status; NDT_Status status;
size_t root_size;
NDT_Index_Id index_id; NDT_Index_Id index_id;
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); root_size = sizeof( NDT_Root) + sizeof(NDT_Index) * (Index_Nb - 1) + Root_Extra_Size;
if( ND_ERROR(status)) return( status);
if( ( status = ND_Allocator_Exec_I( (void **)Root_Ptr_Ptr, NULL, root_size, Handler_Tab[ NDD_HANDLER_ID_ALLOC].Name, (NDT_Allocator *)Handler_Tab[ NDD_HANDLER_ID_ALLOC].Ptr, User_Ptr)) != NDS_OK)
{
return( status);
}
ND_STRCPY( ( *Root_Ptr_Ptr)->Name, Name, NDD_DATASTRUCT_NAME_SIZE); ND_STRCPY( ( *Root_Ptr_Ptr)->Name, Name, NDD_DATASTRUCT_NAME_SIZE);
( *Root_Ptr_Ptr)->Root_Size = root_size;
memcpy( &( ( *Root_Ptr_Ptr)->Handler_Tab), Handler_Tab, NDD_HANDLER_TAB_SIZE); memcpy( &( ( *Root_Ptr_Ptr)->Handler_Tab), Handler_Tab, NDD_HANDLER_TAB_SIZE);
/* To be removed... */ /* To be removed... */
ND_STRCPY( ( *Root_Ptr_Ptr)->Manager_Name, ( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_MANAGER].Name, NDD_HANDLER_NAME_SIZE); 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; ( *Root_Ptr_Ptr)->Manager_Ptr = (NDT_Manager *)( *Root_Ptr_Ptr)->Handler_Tab[ NDD_HANDLER_ID_MANAGER].Ptr;
@ -4015,7 +4511,7 @@ NDT_Status ND_Node_Root_Alloc( NDT_Root **Root_Ptr_Ptr, NDT_DataStruct_Name Na
*/ */
( *Root_Ptr_Ptr)->Own_Value = Own_Value; ( *Root_Ptr_Ptr)->Own_Value = Own_Value;
( *Root_Ptr_Ptr)->User_Ptr = Data_Ptr; ( *Root_Ptr_Ptr)->User_Ptr = User_Ptr;
( *Root_Ptr_Ptr)->Index_Nb = Index_Nb; ( *Root_Ptr_Ptr)->Index_Nb = Index_Nb;
( *Root_Ptr_Ptr)->Index_Open_Count = 0; ( *Root_Ptr_Ptr)->Index_Open_Count = 0;

View File

@ -119,41 +119,18 @@ NDT_Base NDG_Base =
//{
// "", /* 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 */
//};
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
/* */ /* */
/*------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------*/
#define ND_LIBNODE_OPEN_CHECK() if( NDG_Base.Open_Status != NDD_TRUE) { LG_LOG_ERROR_0( "LibNode library is not opened"); return( NDS_ERRAPI); } #define ND_LIBNODE_OPEN_CHECK() if( NDG_Base.Open_Status != NDD_TRUE) { LG_LOG_ERROR_0( "LibNode library is not opened"); return( NDS_ERRAPI); }
#define ND_NOT_NULL_CHECK( ptr, msg) if( !(ptr)) { LG_LOG_ERROR_1( "%s is null", (msg)); return( NDS_ERRAPI); } #define ND_NOT_NULL_CHECK( Ptr, Msg) if( !( Ptr)) { LG_LOG_ERROR_1( "%s is null", ( Msg)); return( NDS_ERRAPI); }
#define ND_HANDLER_NOT_NULL_CHECK( Function_Name, Function_Ptr) if( ( !( Function_Name)) && ( !( Function_Ptr))) { LG_LOG_ERROR_0( "Undefined function name"); return( NDS_ERRAPI); }
#define ND_HANDLER_SYMBOL_FIND( Function_Ptr, Handler_Name, Handler_Ptr) if( ( Handler_Ptr)) { ( Function_Ptr) = ( Handler_Ptr);} \
else { if( ND_Symbol_Find( (void **)&( Function_Ptr), ( Handler_Name)) != NDS_OK) { LG_LOG_ERROR_0( "Cant't find free handler function"); return( NDS_KO);}}
@ -225,12 +202,13 @@ NDT_Status ND_Index_Clear( NDT_Root *, NDT_Index_Id);
/* (I) Index_Nb: Number of index */ /* (I) Index_Nb: Number of index */
/* (I) Index_Type_Ptr: Array of Index type (List, tree, ...) */ /* (I) Index_Type_Ptr: Array of Index type (List, tree, ...) */
/* (I) Handlers_Ptr: Pointer to the data structure handlers */ /* (I) Handlers_Ptr: Pointer to the data structure handlers */
/* (I) Root_Extra_Size: Additional size to be allocated with root node */
/* (I) Own_Value: Flag indicating if the structure is the node owner */ /* (I) Own_Value: Flag indicating if the structure is the node owner */
/* (I) Data_Ptr: User pointer */ /* (I) User_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_Handler *Handler_Tab, 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, size_t Root_Extra_Size, short Own_Value, void *User_Ptr);
@ -350,41 +328,121 @@ 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 */
};
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/* PRIVATE FUNCTIONS */ /* PRIVATE FUNCTIONS */
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------*/
/* Init handler: */
/* - Return extra root size */
/* - Update handler tab */
/*----------------------------------------------------------------------------*/
/* (O) Root_Extra_Size: Pointer on the extra root size */
/* (I) Handler_Tab: Pointer on the handler tab */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Init_Default( size_t *Root_Extra_Size, NDT_Handler *Handler_Tab, void *User_Ptr);
/*----------------------------------------------------------------------------*/
/* Default alloc handler: */
/* malloc() function wrapper with NDT_Status return status */
/*----------------------------------------------------------------------------*/
/* (O) Memory_Ptr_Ptr: Memory pointer address */
/* (I) Root_Ptr: Data structure pointer */
/* (I) Size: Allocation size */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Alloc_Default( void **Memory_Ptr_Ptr, NDT_Root *Root_Ptr, size_t Size, void *User_Ptr);
/*----------------------------------------------------------------------------*/
/* Default free handler: */
/* free() function wrapper with NDT_Status return status */
/*----------------------------------------------------------------------------*/
/* (I) Memory_Ptr: Memory pointer */
/* (I) Root_Ptr: Data structure pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Free_Default( void *Memory_Ptr, NDT_Root *Root_Ptr, void *User_Ptr);
/*----------------------------------------------------------------------------*/
/* Default open handler */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Open_Mode: Open mode */
/* (I) Handler_Open_Name: Free handler function name */
/* (I) Handler_Open_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Open_Default( NDT_Root *Root_Ptr, NDT_Open_Flag Open_Mode, void *User_Ptr);
/*----------------------------------------------------------------------------*/
/* Default close handler */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Close_Mode: Close mode */
/* (I) Handler_Close_Name: Free handler function name */
/* (I) Handler_Close_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Close_Default( NDT_Root *Root_Ptr, NDT_Close_Flag Close_Mode, void *User_Ptr);
/*----------------------------------------------------------------------------*/
/* Default info handler */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Recursive_Offset: Print line offset */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Info_Default( NDT_Root *Root_Ptr, NDT_Recursive_Offset Recursive_Offset);
/*----------------------------------------------------------------------------*/
/* Default lock handler */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Open_Mode: Lock mode */
/* (O) Locked_Ptr: Locked flag */
/* (I) Handler_Lock_Name: Free handler function name */
/* (I) Handler_Lock_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Lock_Default( NDT_Root *Root_Ptr, NDT_Lock_Flag Lock_Mode, bool *Locked_Ptr, void *User_Ptr);
/*----------------------------------------------------------------------------*/
/* Defalt unlock handler */
/*----------------------------------------------------------------------------*/
/* (I) Root_Ptr: Data structure pointer */
/* (I) Handler_Unlock_Name: Free handler function name */
/* (I) Handler_Unlock_Ptr: Free handler function pointer */
/* (I) User_Ptr: User pointer */
/*----------------------------------------------------------------------------*/
NDT_Status ND_Handler_Unlock_Default( NDT_Root *Root_Ptr, void *User_Ptr);
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
void ND_List_Check( NDT_Root *, NDT_Index_Id, int *, int *, FILE *); void ND_List_Check( NDT_Root *, NDT_Index_Id, int *, int *, FILE *);
@ -422,3 +480,35 @@ NDT_Status ND_Symbol_Find( void **, const char *);
void ND_Signal_Trap( int); void ND_Signal_Trap( int);
NDT_Status ND_Address_Check( void *); NDT_Status ND_Address_Check( void *);
/*----------------------------------------------------------------------------*/
/* Post prototype global variable definitions */
/*----------------------------------------------------------------------------*/
NDT_Handler NDG_Handler_Tab_Default[ NDD_HANDLER_NB] =
{
{ "", /* Default Manager function name */
NULL}, /* Default Manager function pointer */
{ "ND_Handler_Init_Default", /* Default Init function name */
( NDT_Handler_Function *)ND_Handler_Init_Default}, /* Default Init function pointer */
{ "ND_Handler_Alloc_Default", /* Default Alloc function name */
( NDT_Handler_Function *)ND_Handler_Alloc_Default}, /* Default Alloc function pointer */
{ "ND_Handler_Free_Default", /* Default Free function name */
( NDT_Handler_Function *)ND_Handler_Free_Default}, /* Default Free function pointer */
{ "NDT_Handler_Open_Default", /* Default Open function name */
( NDT_Handler_Function *)ND_Handler_Open_Default}, /* Default Open function pointer */
{ "NDT_Handler_Close_Default", /* Default Close function name */
( NDT_Handler_Function *)ND_Handler_Close_Default}, /* Default Close function pointer */
{ "NDT_Handler_Info_Default", /* Default Lock function name */
( NDT_Handler_Function *)ND_Handler_Info_Default}, /* Default Lock function pointer */
{ "NDT_Handler_Lock_Default", /* Default Lock function name */
( NDT_Handler_Function *)ND_Handler_Lock_Default}, /* Default Lock function pointer */
{ "NDT_Handler_Unlock_Default", /* Default Unlock function name */
( NDT_Handler_Function *)ND_Handler_Unlock_Default} /* Default Unlock function pointer */
};