- Start Allocation support.
This commit is contained in:
parent
33be3b6070
commit
2967341251
2
Makefile
2
Makefile
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
SUBDIRS := include lib util demo doc
|
SUBDIRS := include lib util doc
|
||||||
|
|
||||||
FILE_DOC := *.txt
|
FILE_DOC := *.txt
|
||||||
|
|
||||||
|
@ -313,16 +313,20 @@ DSD_API DST_Status DS_Library_Stderr_Set_CL( FILE *Out);
|
|||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Création / ouverture d'une structure de données */
|
/* Création / ouverture d'une structure de données */
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* (O) Root : adresse du pointeur sur la racine de la structure */
|
/* (O) Root_Ptr_Ptr: Pointer adress of the new data structure */
|
||||||
/* (I) DS_Name : nom de la structure */
|
/* (I) DS_Name: Data structure name */
|
||||||
/* (I) Type : type de la structure de données */
|
/* (I) Index_Nb: Number of index */
|
||||||
/* (I) Manager_FileName : nom du fichier qui définit les fonctions manager */
|
/* (I) Index_Type_Ptr: Array of Index type (List, tree, ...) */
|
||||||
|
/* (I) Manager_Name: Manager function name */
|
||||||
/* (I) Segment_Size : taille ds segments du heap sous-jacent */
|
/* (I) Segment_Size : taille ds segments du heap sous-jacent */
|
||||||
/* (I) Open_Mode : mode d'ouverture de la structure */
|
/* (I) Open_Mode : mode d'ouverture de la structure */
|
||||||
/* (I) Own_Value : indique si la structure possède ses valeurs */
|
/* (I) Own_Value: Flag indicating if the structure is the node owner */
|
||||||
|
|
||||||
|
/* (I) Manager_FileName : nom du fichier qui définit les fonctions manager */
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
DSD_API DST_Status DS_DataStruct_Open_I( NDT_Root **Root, const char *DS_Name, NDT_Index_Nb, NDT_Index_Type *, const char * Manager_FileName, size_t Segment_Size, DST_Flags Open_Mode, int Own_Value);
|
DSD_API DST_Status DS_DataStruct_Open_I( NDT_Root **Root, char *DS_Name, NDT_Index_Nb, NDT_Index_Type *, char *Manager_FileName, size_t Segment_Size, DST_Flags Open_Mode, short Own_Value);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
DSD_API DST_Status DS_DataStruct_Open_I( const char *DS_Name, NDT_Root **Root, NDT_DataStruct_Type Type, const char * Manager_FileName, size_t Segment_Size, DST_Flags Open_Mode, int Own_Value);
|
DSD_API DST_Status DS_DataStruct_Open_I( const char *DS_Name, NDT_Root **Root, NDT_DataStruct_Type Type, const char * Manager_FileName, size_t Segment_Size, DST_Flags Open_Mode, int Own_Value);
|
||||||
|
206
lib/libdatastr.c
206
lib/libdatastr.c
@ -192,82 +192,84 @@ DST_Status DS_Library_Stderr_Set_I( FILE *Out)
|
|||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Création / ouverture d'une structure de données */
|
/* Création / ouverture d'une structure de données */
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* (I) DS_Name : nom de la structure */
|
|
||||||
/* (O) Root : adresse du pointeur sur la racine de la structure */
|
/* (O) Root : adresse du pointeur sur la racine de la structure */
|
||||||
|
/* (I) DS_Name : nom de la structure */
|
||||||
/* (I) Type : type de la structure de données */
|
/* (I) Type : type de la structure de données */
|
||||||
/* (I) Manager_FileName : nom du fichier qui définit les fonctions manager */
|
/* (I) Manager_FileName : nom du fichier qui définit les fonctions manager */
|
||||||
/* (I) Segment_Size : taille ds segments du heap sous-jacent */
|
/* (I) Segment_Size : taille ds segments du heap sous-jacent */
|
||||||
/* (I) Open_Mode : mode d'ouverture de la structure */
|
/* (I) Open_Mode : mode d'ouverture de la structure */
|
||||||
/* (I) Own_Values : indique si la structure possède ses valeurs */
|
/* (I) Own_Value : indique si la structure possède ses valeurs */
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/*
|
//ND_DataStruct_Open( &OpenedDS_List, 1, &index_type, "DS_OpenedDS_List_Manager", NULL, NULL, NULL, NULL, NULL, TRUE, NULL)) != NDS_OK)
|
||||||
DST_Status DS_DataStruct_Open_I( const char *DS_Name, NDT_Root **Root, NDT_DataStruct_Type Type, const char *Manager_FileName, size_t Segment_Size, DST_Flags Open_Mode, int Own_Values)
|
|
||||||
{
|
|
||||||
DST_Status rc;
|
|
||||||
SMT_Heap * Heap;
|
|
||||||
SMT_DSH * DSH;
|
|
||||||
int Locked, Mode;
|
|
||||||
DST_RootDesc * RootDesc, Tmp_RootDesc;
|
|
||||||
DST_DataStruct * Opened_DataStruct;
|
|
||||||
char * Prefixed_Name = DS_Name_Prefix (DS_Name);
|
|
||||||
union semun Sem_Ctl;
|
|
||||||
|
|
||||||
*Root = NULL;
|
//DST_Status DS_DataStruct_Open_I( NDT_Root **Root, const char *DS_Name, NDT_DataStruct_Type Type, const char *Manager_FileName, size_t Segment_Size, DST_Flags Open_Mode, int Own_Values);
|
||||||
|
|
||||||
|
DST_Status DS_DataStruct_Open_I( NDT_Root **Root_Ptr_Ptr, char *DS_Name, NDT_Index_Nb Index_Nb, NDT_Index_Type *Index_Type_Tab, char *Manager_FileName, size_t Segment_Size, DST_Flags Open_Mode, short Own_Value)
|
||||||
|
{
|
||||||
|
DST_Status status;
|
||||||
|
SMT_Status sm_status;
|
||||||
|
NDT_Status nd_status;
|
||||||
|
SMT_Heap *heap_ptr;
|
||||||
|
SMT_DSH *dsh;
|
||||||
|
int locked, mode;
|
||||||
|
DST_RootDesc *RootDesc, Tmp_RootDesc;
|
||||||
|
DST_DataStruct *Opened_DataStruct;
|
||||||
|
char *Prefixed_Name = DS_Name_Prefix( DS_Name);
|
||||||
|
union semun Sem_Ctl;
|
||||||
|
|
||||||
|
|
||||||
|
*Root_Ptr_Ptr = NULL;
|
||||||
|
|
||||||
/* On définit ce qu'on va faire en fonction du mode d'ouverture demandé et de ce qui existe déjà ou non */
|
/* On définit ce qu'on va faire en fonction du mode d'ouverture demandé et de ce qui existe déjà ou non */
|
||||||
/*
|
|
||||||
if (SM_Heap_Exist (Prefixed_Name) == SMS_YES)
|
if( SM_Heap_Exist( Prefixed_Name) == SMS_YES)
|
||||||
{
|
{
|
||||||
if (DSD_MSK_OPEN (Open_Mode)) Mode = 2;
|
if( DSD_MSK_OPEN( Open_Mode)) mode = 2;
|
||||||
else if (DSD_MSK_NEW (Open_Mode)) Mode = 1;
|
else if( DSD_MSK_NEW( Open_Mode)) mode = 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf (DS_Error_Msg, "Error DS_DataStruct_Open : the data structure already exists and (Flags & DSD_OPEN & DSD_NEW) is false");
|
LG_LOG_ERROR_1( "The data structure: [%s] already exists and (Flags & DSD_OPEN & DSD_NEW) is false", DS_Name);
|
||||||
DS_Error_Print ();
|
|
||||||
|
|
||||||
return DSS_ERRAPI;
|
return( DSS_ERRAPI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (DSD_MSK_CREATE (Open_Mode)) Mode = 3;
|
else if( DSD_MSK_CREATE( Open_Mode)) mode = 3;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf (DS_Error_Msg, "Error DS_DataStruct_Open : the data structure \"%s\" does no exist and (Flags & DSD_CREATE) is false", DS_Name);
|
LG_LOG_ERROR_1( "The data structure: [%s] does no exist and (Flags & DSD_CREATE) is false", DS_Name);
|
||||||
DS_Error_Print ();
|
|
||||||
|
|
||||||
return DSS_ERRAPI;
|
return( DSS_ERRAPI);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (Mode)
|
LG_LOG_TRACE_1( LGD_LOG_LEVEL_DEFAULT, "Creation Mode:(%d)", mode);
|
||||||
|
|
||||||
|
switch( mode)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
|
{
|
||||||
/*--------------- Création d'une nouvelle data structure dans un heap existant -------------*/
|
/*--------------- Création d'une nouvelle data structure dans un heap existant -------------*/
|
||||||
|
|
||||||
/* Ouverture du heap en écriture */
|
/* Ouverture du heap en écriture */
|
||||||
/*
|
|
||||||
rc = SM_Heap_Open (Prefixed_Name, &Heap, 0, SMD_OPEN | SMD_WRITE, &Locked);
|
|
||||||
if (rc != SMS_OK)
|
|
||||||
{
|
|
||||||
sprintf (DS_Error_Msg, "Error DS_DataStruct_Open : unable to open the data structure heap \"%s\" for writing", Prefixed_Name);
|
|
||||||
DS_Error_Print ();
|
|
||||||
|
|
||||||
return rc;
|
if( ( status = SM_Heap_Open( Prefixed_Name, &heap_ptr, 0, SMD_OPEN | SMD_WRITE, &locked)) != SMS_OK)
|
||||||
|
{
|
||||||
|
LG_LOG_ERROR_2( "Unable to open the data structure heap: [%s] for writing, error: (%d)", Prefixed_Name, sm_status);
|
||||||
|
|
||||||
|
return( SMS_KO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Création de la node structure */
|
/* Création de la node structure */
|
||||||
/*
|
|
||||||
Tmp_RootDesc.Heap_Name = Prefixed_Name;
|
Tmp_RootDesc.Heap_Name = Prefixed_Name;
|
||||||
|
|
||||||
rc = ND_DataStruct_Open (Root, Type, "DS_DataStruct_Alloc", "DS_DataStruct_Free", &Tmp_RootDesc, Own_Values);
|
if( ( nd_status = ND_DataStruct_Open( Root_Ptr_Ptr, Index_Nb, Index_Type_Tab, Manager_FileName, NULL, "DS_DataStruct_Alloc", NULL, "DS_DataStruct_Free", NULL, Own_Value, &Tmp_RootDesc)) != NDS_OK)
|
||||||
if (rc != NDS_OK)
|
|
||||||
{
|
{
|
||||||
sprintf (DS_Error_Msg, "Error DS_DataStruct_Open : unable to create a new node structure in the existing heap \"%s\"", Heap->Name);
|
LG_LOG_ERROR_2( "Unable to create a new node structure in the existing heap: [%s], error: (%d)", heap_ptr->Name, nd_status);
|
||||||
DS_Error_Print ();
|
|
||||||
|
|
||||||
if (Locked == TRUE) SM_Heap_Unlock (Heap);
|
if( locked == TRUE) SM_Heap_Unlock( heap_ptr);
|
||||||
*Root = NULL;
|
*Root_Ptr_Ptr = NULL;
|
||||||
|
|
||||||
return rc;
|
return( SMS_KO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocation de mémoire pour la description de la nouvelle data structure */
|
/* Allocation de mémoire pour la description de la nouvelle data structure */
|
||||||
@ -279,7 +281,7 @@ DST_Status DS_DataStruct_Open_I( const char *DS_Name, NDT_Root **Root, NDT_Da
|
|||||||
DS_Error_Print ();
|
DS_Error_Print ();
|
||||||
|
|
||||||
DS_DataStruct_Free (*Root, &Tmp_RootDesc);
|
DS_DataStruct_Free (*Root, &Tmp_RootDesc);
|
||||||
if (Locked == TRUE) SM_Heap_Unlock (Heap);
|
if (locked == TRUE) SM_Heap_Unlock (Heap);
|
||||||
*Root = NULL;
|
*Root = NULL;
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
@ -319,9 +321,10 @@ DST_Status DS_DataStruct_Open_I( const char *DS_Name, NDT_Root **Root, NDT_Da
|
|||||||
}
|
}
|
||||||
|
|
||||||
return DSS_OK;
|
return DSS_OK;
|
||||||
|
*/
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
/*
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
/*--------------- Ouverture d'une data structure existante ------------------*/
|
/*--------------- Ouverture d'une data structure existante ------------------*/
|
||||||
@ -371,40 +374,36 @@ DST_Status DS_DataStruct_Open_I( const char *DS_Name, NDT_Root **Root, NDT_Da
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
*/
|
||||||
case 3:
|
case 3:
|
||||||
|
{
|
||||||
/*--------------- Création d'une nouvelle structure de données dans un nouveau heap -----------------*/
|
/*--------------- Création d'une nouvelle structure de données dans un nouveau heap -----------------*/
|
||||||
/*
|
|
||||||
if (!Manager_FileName)
|
if( !Manager_FileName)
|
||||||
{
|
{
|
||||||
sprintf (DS_Error_Msg, "Error DS_DataStruct_Open : the manager file name (.so) is undefined");
|
LG_LOG_ERROR_0( "The manager file name (.so) is undefined");
|
||||||
DS_Error_Print ();
|
return( DSS_ERRAPI);
|
||||||
return DSS_ERRAPI;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Création d'un nouveau heap */
|
/* Création d'un nouveau heap */
|
||||||
/*
|
|
||||||
rc = SM_Heap_Open (Prefixed_Name, &Heap, Segment_Size, SMD_CREATE | SMD_WRITE, &Locked);
|
if( ( sm_status = SM_Heap_Open( Prefixed_Name, &heap_ptr, Segment_Size, ( SMD_CREATE | SMD_WRITE), &locked)) != SMS_OK)
|
||||||
if (rc != SMS_OK)
|
|
||||||
{
|
{
|
||||||
sprintf (DS_Error_Msg, "Error DS_DataStruct_Open : unable to create a heap for the data structure \"%s\"", DS_Name);
|
LG_LOG_ERROR_2( "Unable to create a heap for the data structure [%s], error: (%d)", DS_Name, sm_status);
|
||||||
DS_Error_Print ();
|
return( sm_status);
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Création de la structure de données dans le heap */
|
/* Création de la structure de données dans le heap */
|
||||||
/*
|
|
||||||
Tmp_RootDesc.Heap_Name = Prefixed_Name;
|
Tmp_RootDesc.Heap_Name = Prefixed_Name;
|
||||||
|
|
||||||
rc = ND_DataStruct_Open (Root, Type, "DS_DataStruct_Alloc", "DS_DataStruct_Free", &Tmp_RootDesc, Own_Values);
|
if( ( nd_status = ND_DataStruct_Open( Root_Ptr_Ptr, Index_Nb, Index_Type_Tab, Manager_FileName, NULL, "DS_DataStruct_Alloc", NULL, "DS_DataStruct_Free", NULL, Own_Value, &Tmp_RootDesc)) != NDS_OK)
|
||||||
if (rc != NDS_OK)
|
|
||||||
{
|
{
|
||||||
sprintf (DS_Error_Msg, "Error DS_DataStruct_Open : unable to create the node structure");
|
LG_LOG_ERROR_2( "Unable to create a new node structure in new heap: [%s], error: (%d)", heap_ptr->Name, nd_status);
|
||||||
DS_Error_Print ();
|
SM_Heap_End( Prefixed_Name);
|
||||||
SM_Heap_End (Prefixed_Name);
|
*Root_Ptr_Ptr = NULL;
|
||||||
*Root = NULL;
|
|
||||||
return rc;
|
return( SMS_KO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocation de mémoire pour la description de la structure */
|
/* Allocation de mémoire pour la description de la structure */
|
||||||
@ -448,11 +447,14 @@ DST_Status DS_DataStruct_Open_I( const char *DS_Name, NDT_Root **Root, NDT_Da
|
|||||||
*Root = NULL;
|
*Root = NULL;
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* On incrémente le sémaphore qui compte le nombre de processus qui ouvrent la structure */
|
/* On incrémente le sémaphore qui compte le nombre de processus qui ouvrent la structure */
|
||||||
@ -528,8 +530,8 @@ DST_Status DS_DataStruct_Open_I( const char *DS_Name, NDT_Root **Root, NDT_Da
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return DSS_OK;
|
return( DSS_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2967,50 +2969,54 @@ DST_Status DS_DataStruct_IsOpen ( const char * DS_Name, NDT_Root ** Root )
|
|||||||
return DSS_YES;
|
return DSS_YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Fonction d'allocation attachée à une structure de données : */
|
/* Fonction d'allocation attachée à une structure de données : */
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/*
|
|
||||||
DST_Status DS_DataStruct_Alloc ( size_t Size, void ** Ptr, void * Data )
|
DST_Status DS_DataStruct_Alloc ( void **Ptr_Ptr, size_t Size, void *Data_Ptr)
|
||||||
{
|
{
|
||||||
DST_Status rc;
|
DST_Status status;
|
||||||
SMT_Heap * Heap;
|
SMT_Status sm_status;
|
||||||
int Locked;
|
SMT_Heap *heap_ptr;
|
||||||
DST_RootDesc * RootDesc = (DST_RootDesc *)Data;
|
int locked;
|
||||||
char * Heap_Name = RootDesc->Heap_Name;
|
DST_RootDesc *RootDesc = (DST_RootDesc *)Data_Ptr;
|
||||||
|
// char *heap_name = RootDesc->Heap_Name;
|
||||||
|
|
||||||
rc = SM_Heap_IsOpen (Heap_Name, &Heap);
|
|
||||||
if (rc != SMS_YES)
|
if( ( sm_status = SM_Heap_IsOpen( RootDesc->Heap_Name, &heap_ptr)) != SMS_YES)
|
||||||
{
|
{
|
||||||
sprintf (DS_Error_Msg, "Error DS_DataStruct_Alloc : the data structure heap \"%s\" is not open", Heap_Name);
|
LG_LOG_ERROR_1( "The data structure heap: [%s] is not open", RootDesc->Heap_Name);
|
||||||
DS_Error_Print ();
|
|
||||||
|
|
||||||
return rc;
|
return( DSS_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Verrouillage du heap en écriture */
|
/* Verrouillage du heap en écriture */
|
||||||
/*
|
|
||||||
rc = SM_Heap_Lock (Heap, SMD_WRITE, &Locked);
|
|
||||||
if (rc != DSS_OK)
|
|
||||||
{
|
|
||||||
sprintf (DS_Error_Msg, "Error DS_DataStruct_Alloc : unable to lock the data structure heap \"%s\" for writing", Heap_Name);
|
|
||||||
DS_Error_Print ();
|
|
||||||
|
|
||||||
return rc;
|
if( ( sm_status = SM_Heap_Lock( heap_ptr, SMD_WRITE, &locked)) != SMS_OK)
|
||||||
|
{
|
||||||
|
LG_LOG_ERROR_2( "Unable to lock the data structure heap: [%s] for writing, error: (%d)", RootDesc->Heap_Name, sm_status);
|
||||||
|
|
||||||
|
return( DSS_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Allocation du chunk */
|
/* Allocation du chunk */
|
||||||
/*
|
|
||||||
rc = SM_Chunk_Alloc (Heap, Size, Ptr);
|
|
||||||
if (rc != SMS_OK)
|
|
||||||
{
|
|
||||||
if (Locked == TRUE) SM_Heap_Unlock (Heap);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if( ( sm_status = SM_Chunk_Alloc( heap_ptr, Size, Ptr_Ptr)) != SMS_OK)
|
||||||
|
{
|
||||||
|
LG_LOG_ERROR_3( "Unable to alloc size: (%d) in the heap: [%s] for writing, error: (%d)", Size, RootDesc->Heap_Name, sm_status);
|
||||||
|
|
||||||
|
if( locked == TRUE) SM_Heap_Unlock( heap_ptr);
|
||||||
|
return( DSS_KO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Déverrouillage de la data structure si besoin */
|
/* Déverrouillage de la data structure si besoin */
|
||||||
/*
|
|
||||||
if (Locked == TRUE) SM_Heap_Unlock (Heap);
|
if( locked == TRUE) SM_Heap_Unlock( heap_ptr);
|
||||||
|
|
||||||
return DSS_OK;
|
return DSS_OK;
|
||||||
}
|
}
|
||||||
@ -3075,14 +3081,14 @@ void DS_Error_Print ( void )
|
|||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Pour préfixer les noms de heap avec l'identifiant de la librairie */
|
/* Pour préfixer les noms de heap avec l'identifiant de la librairie */
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/*
|
|
||||||
static char * DS_Name_Prefix ( const char * Name )
|
static char *DS_Name_Prefix( const char *Name )
|
||||||
{
|
{
|
||||||
static char Prefixed [256];
|
static char Prefixed [256];
|
||||||
|
|
||||||
sprintf (Prefixed, "%s/%s", DS_PREFIX, Name);
|
sprintf (Prefixed, "%s/%s", DS_PREFIX, Name);
|
||||||
|
|
||||||
return Prefixed;
|
return( Prefixed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
@ -111,10 +111,15 @@ DST_Status DS_Semaphore_Create (NDT_Root * Root);
|
|||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
DST_Status DS_Semaphore_Operate (int, struct sembuf *, unsigned int);
|
DST_Status DS_Semaphore_Operate (int, struct sembuf *, unsigned int);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Fonction d'allocation attachée à une structure de données : */
|
/* Fonction d'allocation attachée à une structure de données : */
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
DST_Status DS_DataStruct_Alloc ( size_t Size, void ** Ptr, void * Data );
|
|
||||||
|
DST_Status DS_DataStruct_Alloc ( void **Ptr, size_t Size, void *Data );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Fonction de désallocation attachée à une structure de données : */
|
/* Fonction de désallocation attachée à une structure de données : */
|
||||||
@ -126,10 +131,14 @@ DST_Status DS_DataStruct_Free ( void * Ptr, void * Data );
|
|||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
void DS_Error_Print ( void );
|
void DS_Error_Print ( void );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Pour préfixer les noms de heap avec l'identifiant de la librairie */
|
/* Pour préfixer les noms de heap avec l'identifiant de la librairie */
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
static char * DS_Name_Prefix (const char * Name);
|
static char *DS_Name_Prefix (const char *Name);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
/* Teste si une data structure a déjà été ouverte par le processus courant */
|
/* Teste si une data structure a déjà été ouverte par le processus courant */
|
||||||
|
@ -194,6 +194,9 @@ NDT_Status Module_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod
|
|||||||
|
|
||||||
|
|
||||||
Command_Name = "NDD_CMD_VALUE_ALLOC";
|
Command_Name = "NDD_CMD_VALUE_ALLOC";
|
||||||
|
|
||||||
|
LG_LOG_TRACE_0( LGD_LOG_LEVEL_DEFAULT, "CMD_VALUE_ALLOC called...");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if( DS_Alloc( Root, sizeof( T_Module) + strlen( Nom) + 1, (void **)Module) == DSS_OK)
|
if( DS_Alloc( Root, sizeof( T_Module) + strlen( Nom) + 1, (void **)Module) == DSS_OK)
|
||||||
{
|
{
|
||||||
@ -572,15 +575,17 @@ int Menu_Print( NDT_Root *Root )
|
|||||||
|
|
||||||
int main( int argc, char **argv)
|
int main( int argc, char **argv)
|
||||||
{
|
{
|
||||||
LGT_Status lg_status;
|
DST_Status status;
|
||||||
int rc;
|
LGT_Status lg_status;
|
||||||
NDT_Root *Root = NULL;
|
int rc;
|
||||||
char *tmp;
|
NDT_Root *Root_Ptr = NULL;
|
||||||
int n, m, i, j;
|
NDT_Index_Type index_type = ( NDD_INDEX_STATUS_OPENED | NDD_INDEX_TYPE_LIST | NDD_INDEX_SUBTYPE_FIFO);
|
||||||
int choice, Nb_Removed, Locked;
|
char *tmp;
|
||||||
int Nb_Detected, Nb_Corrected;
|
int n, m, i, j;
|
||||||
T_Module *Module, Ref_Module;
|
int choice, Nb_Removed, Locked;
|
||||||
NDT_Node *Node;
|
int Nb_Detected, Nb_Corrected;
|
||||||
|
T_Module *Module, Ref_Module;
|
||||||
|
NDT_Node *Node;
|
||||||
|
|
||||||
|
|
||||||
if( ( lg_status = LG_Library_Open( LGD_LOG_WRITER_DEFAULT, true)) != LGS_OK)
|
if( ( lg_status = LG_Library_Open( LGD_LOG_WRITER_DEFAULT, true)) != LGS_OK)
|
||||||
@ -605,7 +610,7 @@ int main( int argc, char **argv)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
choice = Menu_Print( Root);
|
choice = Menu_Print( Root_Ptr);
|
||||||
|
|
||||||
while (choice != QUIT)
|
while (choice != QUIT)
|
||||||
{
|
{
|
||||||
@ -615,17 +620,25 @@ int main( int argc, char **argv)
|
|||||||
{
|
{
|
||||||
fprintf( stdout, "\nNom de la structure à créer ? ");
|
fprintf( stdout, "\nNom de la structure à créer ? ");
|
||||||
fgets( DataStruct_Name, 100, stdin);
|
fgets( DataStruct_Name, 100, stdin);
|
||||||
/*
|
if( strlen( DataStruct_Name) < 2)
|
||||||
if( DS_DataStruct_Open( DataStruct_Name, &Root, NDD_DS_LIST | NDD_MN_FIFO, MANAGER_FILE_NAME, 0, DSD_CREATE, TRUE) != DSS_OK)
|
|
||||||
{
|
{
|
||||||
printf ("\nNOK\n");
|
fprintf( stdout, "Bad name!\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy( Root->Manager, "Module_Manager");
|
DataStruct_Name[ strlen( DataStruct_Name) - 1] = 0;
|
||||||
printf( "\nStructure créée : OK\n");
|
if( ( status = DS_DataStruct_Open( &Root_Ptr, DataStruct_Name, 1, &index_type, MANAGER_FILE_NAME, 0, DSD_CREATE, TRUE)) != DSS_OK)
|
||||||
|
{
|
||||||
|
LG_LOG_ERROR_1( "Can't create data structure: (%d)", status);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// strcpy( Root->Manager, "Module_Manager");
|
||||||
|
|
||||||
|
LG_LOG_INFO_1( "Data structure: [%s] created", DataStruct_Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -929,7 +942,7 @@ int main( int argc, char **argv)
|
|||||||
fprintf (stdout, "\nChoix %d non défini\n", choice);
|
fprintf (stdout, "\nChoix %d non défini\n", choice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
choice = Menu_Print( Root);
|
choice = Menu_Print( Root_Ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
DS_Library_Close();
|
DS_Library_Close();
|
||||||
|
Loading…
Reference in New Issue
Block a user