- Fix SM_Name_Prefix() implementation,

- Minor code cleanup.
This commit is contained in:
Arnaud G. GIBERT 2024-04-15 16:54:18 +02:00
parent 604b749d4e
commit 04660e4607
3 changed files with 389 additions and 284 deletions

View File

@ -33,13 +33,16 @@
#define _LIBSM
#ifdef __cplusplus
extern "C" {
//extern "C" {
#endif
#include <stdarg.h>
#include <sys/types.h>
#include <node.h>
/* Code retour des fonctions constituant l'API */
typedef long SMT_Status;
@ -59,6 +62,13 @@ extern "C" {
#define SM_ERROR(s) ((s) < 0) /* Tous les codes retour négatifs correspondent à des erreurs */
#define SMD_NAME_LEN (short) 256
#define SMD_NAME_SIZE (SMD_NAME_LEN + 1)
typedef int SMT_Flags;
#define SMD_UNDEF 0
@ -72,6 +82,8 @@ extern "C" {
/* NB : pour l'ouverture de la librairie, les valeurs SMD_OPEN et SMD_CREATE sont mutuellement exclusives */
/* Flags de verrouillage */
#define SMD_READ 0x04 /* verrou partagé */
@ -80,6 +92,8 @@ extern "C" {
#define SMD_LOCK_MSK(a) ((a) & (SMD_READ|SMD_WRITE))
/* Mode de debug sur l'ouverture de la librairie */
#define SMD_DEBUG_NONE 0x00 /* pour n'afficher aucun message généré par les diverses librairies */
@ -88,6 +102,8 @@ extern "C" {
#define SMD_DEBUG_MSK(a) ((a) & (SMD_DEBUG|SMD_DEBUG_ALL))
/* Différentes types de configuration d'un heap */
typedef int SMT_Config;
@ -99,15 +115,21 @@ extern "C" {
#define SMD_DEFAULT_COMPRESS 1000 /* si + de 1000 chunks libres, alors compression du heap */
/* Différentes valeurs de configuration */
#define SMD_UNLIMITED 0
#define SMD_NO_AUTO_COMPRESS 0
/* Nom du heap système */
#define HEAP_SYSTEM "system"
#ifndef FALSE
#define FALSE 0
#endif
@ -116,12 +138,103 @@ extern "C" {
#define TRUE 1
#endif
#ifdef _LIBSHMEM_C_
char SM_Error_Msg [512];
#else
extern char SM_Error_Msg [512];
#endif
/*------------------------------------------------------------------------------*/
/* Structure de la base de heaps */
/*------------------------------------------------------------------------------*/
typedef struct {
int SysMemId; /* Id de la 1ère zone de mémoire partagée de la base */
int DataMemId; /* Id de la 2ème zone de mémoire partagée de la base */
size_t Size; /* Taille de la zone de mémoire partagée */
int SemId; /* Id du sémaphore pour la gestion des verrous */
NDT_Root * MHR; /* Memory Heap Root : racine de la liste de heap */
pid_t Creator; /* Id du processus créateur de la base */
pid_t Writer; /* Id du dernier processus ayant accédé en écriture à la base */
void * Free; /* Pointeur sur la première zone libre de la base */
void * Attach; /* Adresse du dernier attachement */
size_t Segment_Size; /* Taille par défaut des segments qui composeront les heaps */
} SMT_Base;
/* Référence sur la base de heaps */
#ifdef _LIBSHMEM_C_
SMT_Base * SM_Base;
#else
extern SMT_Base * SM_Base;
#endif
/*------------------------------------------------------------------------------*/
/* Structure d'un MHH (Memory Heap Header) */
/* Rappel : un MHH est une valeur attachée à un MHN (Memory Heap Node) */
/*------------------------------------------------------------------------------*/
typedef struct {
char Name [SMD_NAME_SIZE]; /* Nom du heap */
int SemId; /* Id du sémaphore pour la gestion des verrous */
NDT_Root *DSR; /* Data Segment Root */
NDT_Root *ACR; /* Allocated Chunks Root */
NDT_Root *FCR; /* Free Chunks Root */
pid_t Writer; /* Id du processus ayant accédé en dernier au MHH en écriture */
int State; /* Etat d'un heap (valide, non validé ou corrompu) */
size_t Segment_Size; /* Taille des segments de mémoire composant le heap */
size_t Limit_Size; /* Taille limite du heap (par défaut : pas de limite) */
int Auto_Compress; /* Nombre de chunks libres à partir duquel le heap est automatiquement compressé */
long Compress_Nb; /* Nomber of time the heap has been compressed */
} SMT_MHH;
/* Heap ouvert */
typedef struct {
char * Name;
SMT_MHH * MHH;
SMT_Flags Lock_Mode; /* Mode dans lequel le heap est verrouillé */
int Nb_Seg; /* Nombre de segments du heap lors de son ouverture */
} SMT_Heap;
/*------------------------------------------------------------------------------*/
/* Structure d'un DSH (Data Segment Header) */
/* Rappel : un DSH est une valeur attachée à un DSN (noeud de DSR) */
/*------------------------------------------------------------------------------*/
typedef struct {
int MemId; /* Id de la zone de mémoire partagée */
size_t Size; /* Taille de la zone de mémoire partagée */
void * Start; /* Adresse de début de la zone de mémoire partagée */
} SMT_DSH;
/*------------------------------------------------------------------------------*/
/* Structure d'un chunk */
/* Rappel : un chunk est la valeur attachée à un noeud de ACR ou FCR */
/*------------------------------------------------------------------------------*/
typedef struct {
size_t Size; /* Taille allouée au chunk */
void * Data; /* Adresse de la zone de données du chunk */
} SMT_Chunk;
/* Alias API definition */
#ifndef SM_MODE
#define SM_MODE 0
#endif
@ -174,79 +287,7 @@ extern "C" {
#endif
/*------------------------------------------------------------------------------*/
/* Structure de la base de heaps */
/*------------------------------------------------------------------------------*/
typedef struct {
int SysMemId; /* Id de la 1ère zone de mémoire partagée de la base */
int DataMemId; /* Id de la 2ème zone de mémoire partagée de la base */
size_t Size; /* Taille de la zone de mémoire partagée */
int SemId; /* Id du sémaphore pour la gestion des verrous */
NDT_Root * MHR; /* Memory Heap Root : racine de la liste de heap */
pid_t Creator; /* Id du processus créateur de la base */
pid_t Writer; /* Id du dernier processus ayant accédé en écriture à la base */
void * Free; /* Pointeur sur la première zone libre de la base */
void * Attach; /* Adresse du dernier attachement */
size_t Segment_Size; /* Taille par défaut des segments qui composeront les heaps */
} SMT_Base;
/* Référence sur la base de heaps */
#ifdef _LIBSHMEM_C_
SMT_Base * SM_Base;
#else
extern SMT_Base * SM_Base;
#endif
/*------------------------------------------------------------------------------*/
/* Structure d'un MHH (Memory Heap Header) */
/* Rappel : un MHH est une valeur attachée à un MHN (Memory Heap Node) */
/*------------------------------------------------------------------------------*/
typedef struct {
char Name [256]; /* Nom du heap */
int SemId; /* Id du sémaphore pour la gestion des verrous */
NDT_Root * DSR; /* Data Segment Root */
NDT_Root * ACR; /* Allocated Chunks Root */
NDT_Root * FCR; /* Free Chunks Root */
pid_t Writer; /* Id du processus ayant accédé en dernier au MHH en écriture */
int State; /* Etat d'un heap (valide, non validé ou corrompu) */
size_t Segment_Size; /* Taille des segments de mémoire composant le heap */
size_t Limit_Size; /* Taille limite du heap (par défaut : pas de limite) */
int Auto_Compress; /* Nombre de chunks libres à partir duquel le heap est automatiquement compressé */
long Compress_Nb; /* Nomber of time the heap has been compressed */
} SMT_MHH;
/* Heap ouvert */
typedef struct {
char * Name;
SMT_MHH * MHH;
SMT_Flags Lock_Mode; /* Mode dans lequel le heap est verrouillé */
int Nb_Seg; /* Nombre de segments du heap lors de son ouverture */
} SMT_Heap;
/*------------------------------------------------------------------------------*/
/* Structure d'un DSH (Data Segment Header) */
/* Rappel : un DSH est une valeur attachée à un DSN (noeud de DSR) */
/*------------------------------------------------------------------------------*/
typedef struct {
int MemId; /* Id de la zone de mémoire partagée */
size_t Size; /* Taille de la zone de mémoire partagée */
void * Start; /* Adresse de début de la zone de mémoire partagée */
} SMT_DSH;
/*------------------------------------------------------------------------------*/
/* Structure d'un chunk */
/* Rappel : un chunk est la valeur attachée à un noeud de ACR ou FCR */
/*------------------------------------------------------------------------------*/
typedef struct {
size_t Size; /* Taille allouée au chunk */
void * Data; /* Adresse de la zone de données du chunk */
} SMT_Chunk;
/*------------------------------------------------------------------------------*/
/* Ouverture d'une instance de la librairie */
@ -258,6 +299,8 @@ extern "C" {
SMT_Status SM_Library_Open_I ( int Instance, const char * Context, SMT_Flags Flags );
SMT_Status SM_Library_Open_C ( int Instance, const char * Context, SMT_Flags Flags );
/*------------------------------------------------------------------------------*/
/* Récupération du numéro de l'instance utilisée */
/*------------------------------------------------------------------------------*/
@ -266,6 +309,8 @@ extern "C" {
SMT_Status SM_Library_Instance_Get_I ( int * Instance);
SMT_Status SM_Library_Instance_Get_C ( int * Instance);
/*------------------------------------------------------------------------------*/
/* Changement de contexte d'utilisation de la librairie */
/*------------------------------------------------------------------------------*/
@ -274,6 +319,8 @@ extern "C" {
SMT_Status SM_Library_Context_Set_I ( const char * Context );
SMT_Status SM_Library_Context_Set_C ( const char * Context );
/*------------------------------------------------------------------------------*/
/* Récupération du nom du contexte utilisé */
/*------------------------------------------------------------------------------*/
@ -282,6 +329,8 @@ extern "C" {
SMT_Status SM_Library_Context_Get_I ( char ** Context );
SMT_Status SM_Library_Context_Get_C ( char ** Context );
/*------------------------------------------------------------------------------*/
/* Fermeture de l'instance de la librairie */
/*------------------------------------------------------------------------------*/
@ -290,6 +339,8 @@ extern "C" {
SMT_Status SM_Library_Close_I ( SMT_Flags Flags );
SMT_Status SM_Library_Close_C ( SMT_Flags Flags );
/*------------------------------------------------------------------------------*/
/* Affichage des informations de la base de mémoires partagées */
/*------------------------------------------------------------------------------*/
@ -298,18 +349,24 @@ extern "C" {
SMT_Status SM_Library_Dump_I ( FILE * Out );
SMT_Status SM_Library_Dump_C ( FILE * Out );
/*------------------------------------------------------------------------------*/
/* Libération de tous les verrous (base, heap) */
/*------------------------------------------------------------------------------*/
SMT_Status SM_Library_Unlock_I ( void );
SMT_Status SM_Library_Unlock_C ( void );
/*------------------------------------------------------------------------------*/
/* Définition de la sortie standard des messages d'erreur de la librairie */
/*------------------------------------------------------------------------------*/
SMT_Status SM_Library_Stderr_Set_I ( FILE * Out );
SMT_Status SM_Library_Stderr_Set_C ( FILE * Out );
/*------------------------------------------------------------------------------*/
/* Test d'existence d'un heap */
/*------------------------------------------------------------------------------*/
@ -318,6 +375,8 @@ extern "C" {
SMT_Status SM_Heap_Exist_I ( const char * Heap_Name );
SMT_Status SM_Heap_Exist_C ( const char * Heap_Name );
/*------------------------------------------------------------------------------*/
/* Ouverture/création d'un heap */
/*------------------------------------------------------------------------------*/
@ -330,6 +389,8 @@ extern "C" {
SMT_Status SM_Heap_Open_I ( const char * Heap_Name, SMT_Heap ** Heap, size_t Seg_Size, SMT_Flags Flags, int * Locked );
SMT_Status SM_Heap_Open_C ( const char * Heap_Name, SMT_Heap ** Heap, size_t Seg_Size, SMT_Flags Flags, int * Locked );
/*------------------------------------------------------------------------------*/
/* Teste si un heap a déjà été ouvert par le processus courant */
/*------------------------------------------------------------------------------*/
@ -339,6 +400,8 @@ extern "C" {
SMT_Status SM_Heap_IsOpen_I ( const char * Heap_Name, SMT_Heap ** Heap );
SMT_Status SM_Heap_IsOpen_C ( const char * Heap_Name, SMT_Heap ** Heap );
/*------------------------------------------------------------------------------*/
/* Fermeture d'un heap */
/*------------------------------------------------------------------------------*/
@ -347,6 +410,8 @@ extern "C" {
SMT_Status SM_Heap_Close_I ( SMT_Heap * Heap );
SMT_Status SM_Heap_Close_C ( SMT_Heap * Heap );
/*------------------------------------------------------------------------------*/
/* Destruction d'un heap */
/*------------------------------------------------------------------------------*/
@ -355,6 +420,8 @@ extern "C" {
SMT_Status SM_Heap_End_I ( const char * Heap_Name );
SMT_Status SM_Heap_End_C ( const char * Heap_Name );
/*------------------------------------------------------------------------------*/
/* Compression d'un heap */
/*------------------------------------------------------------------------------*/
@ -364,6 +431,8 @@ extern "C" {
SMT_Status SM_Heap_Compress_I ( SMT_Heap * Heap, size_t * Compress );
SMT_Status SM_Heap_Compress_C ( SMT_Heap * Heap, size_t * Compress );
/*------------------------------------------------------------------------------*/
/* Configuration d'un heap */
/*------------------------------------------------------------------------------*/
@ -373,6 +442,8 @@ extern "C" {
SMT_Status SM_Heap_Config_I ( SMT_Heap * Heap, SMT_Config Tag, ... );
SMT_Status SM_Heap_Config_C ( SMT_Heap * Heap, SMT_Config Tag, ... );
/*------------------------------------------------------------------------------*/
/* Vérification/correction des structures d'un heap : */
/*------------------------------------------------------------------------------*/
@ -384,6 +455,8 @@ extern "C" {
SMT_Status SM_Heap_Check_I ( SMT_Heap * Heap, int * Nb_Detected, int * Nb_Corrected, FILE * Out);
SMT_Status SM_Heap_Check_C ( SMT_Heap * Heap, int * Nb_Detected, int * Nb_Corrected, FILE * Out);
/*------------------------------------------------------------------------------*/
/* Pose d'un verrou sur un heap */
/*------------------------------------------------------------------------------*/
@ -394,6 +467,8 @@ extern "C" {
SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Flags, int * Locked );
SMT_Status SM_Heap_Lock_C ( SMT_Heap * Heap, SMT_Flags Flags, int * Locked );
/*------------------------------------------------------------------------------*/
/* Libération d'un verrou sur un heap */
/*------------------------------------------------------------------------------*/
@ -402,6 +477,8 @@ extern "C" {
SMT_Status SM_Heap_Unlock_I ( SMT_Heap * Heap );
SMT_Status SM_Heap_Unlock_C ( SMT_Heap * Heap );
/*------------------------------------------------------------------------------*/
/* Allocation d'un chunk dans un heap */
/*------------------------------------------------------------------------------*/
@ -412,6 +489,8 @@ extern "C" {
SMT_Status SM_Chunk_Alloc_I ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr );
SMT_Status SM_Chunk_Alloc_C ( SMT_Heap * Heap, size_t Alloc_Size, void ** Ptr );
/*------------------------------------------------------------------------------*/
/* Désallocation d'un chunk */
/*------------------------------------------------------------------------------*/
@ -421,6 +500,8 @@ extern "C" {
SMT_Status SM_Chunk_Free_I ( SMT_Heap * Heap, void * Ptr );
SMT_Status SM_Chunk_Free_C ( SMT_Heap * Heap, void * Ptr );
#ifdef __cplusplus
}
#endif

View File

@ -458,10 +458,12 @@ SMT_Status SM_Heap_Exist_I ( const char *Heap_Name)
{
NDT_Node *Node;
SMT_MHH *MHH;
char *Prefixed_Name = SM_Name_Prefix( Heap_Name);
char prefixed_name[ SMD_NAME_SIZE];
int Locked = FALSE;
SM_Name_Prefix( prefixed_name, Heap_Name);
if( strcmp( Heap_Name, HEAP_SYSTEM))
{
/* Verrouillage du heap système en lecture */
@ -477,7 +479,7 @@ SMT_Status SM_Heap_Exist_I ( const char *Heap_Name)
{
MHH = (SMT_MHH *)( Node->Value);
if (!strcmp( Prefixed_Name, MHH->Name))
if( !strcmp( prefixed_name, MHH->Name))
{
return( SMS_YES);
}
@ -514,7 +516,7 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
SMT_MHH *MHH;
NDT_Node *Node;
SMT_DSH *New_DSH;
char *Prefixed_Name;
char prefixed_name[ SMD_NAME_SIZE];
union semun Sem_Ctl;
int SemId;
SMT_Status rc;
@ -551,7 +553,9 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
}
}
Prefixed_Name = SM_Name_Prefix( Heap_Name);
SM_Name_Prefix( prefixed_name, Heap_Name);
/* On regarde si le heap existe déjà dans la base */
@ -564,7 +568,7 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
/* Ouverture d'un heap existant */
strcpy( To_Find.Name, Prefixed_Name);
strcpy( To_Find.Name, prefixed_name);
ND_Index_Node_Find( &Node, SM_Base->MHR, NDD_INDEX_PRIMARY, &To_Find, NULL);
MHH = (SMT_MHH *)( Node->Value);
@ -572,13 +576,13 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
*Heap = (SMT_Heap *) malloc( sizeof( SMT_Heap));
if( !*Heap)
{
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to allocate memory for the opened heap \"%s\"", Prefixed_Name);
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to allocate memory for the opened heap \"%s\"", prefixed_name);
SM_Error_Print();
return( SMS_ERRMEM);
}
( *Heap)->Name = strdup( Prefixed_Name);
( *Heap)->Name = strdup( prefixed_name);
( *Heap)->MHH = MHH;
( *Heap)->Lock_Mode = SMD_NO_LOCK;
@ -592,7 +596,7 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
if( rc != SMS_OK)
{
sprintf (SM_Error_Msg, "SM_Heap_Open : unable to open one of the data segments of heap \"%s\"", Prefixed_Name);
sprintf (SM_Error_Msg, "SM_Heap_Open : unable to open one of the data segments of heap \"%s\"", prefixed_name);
SM_Error_Print ();
goto Error1;
@ -609,7 +613,7 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
if( rc != SMS_OK)
{
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to lock heap \"%s\" for %s", Prefixed_Name, Open_Mode & SMD_READ ? "reading" : "writing");
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to lock heap \"%s\" for %s", prefixed_name, Open_Mode & SMD_READ ? "reading" : "writing");
SM_Error_Print();
goto Error1;
@ -621,7 +625,7 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
if( rc != NDS_OK)
{
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to add heap \"%s\" to the opened heap cache", Prefixed_Name);
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to add heap \"%s\" to the opened heap cache", prefixed_name);
SM_Error_Print();
goto Error2;
@ -638,16 +642,22 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
}
}
fprintf( stderr, "Heap not Open!!!\n");
if( !( Open_Mode & SMD_CREATE))
{
sprintf( SM_Error_Msg, "SM_Heap_Open : the heap \"%s\" does no exist and (Open_Mode & SMD_CREATE) is false", Prefixed_Name);
sprintf( SM_Error_Msg, "SM_Heap_Open : the heap \"%s\" does no exist and (Open_Mode & SMD_CREATE) is false", prefixed_name);
SM_Error_Print();
return( SMS_ERRAPI);
}
fprintf( stderr, "Heap to be created!!!\n");
/*Alloc du MHH qui fait l'alloccation du premier segment de donnees*/
rc = ND_Value_Alloc( (void **)&MHH, SM_Base->MHR, Prefixed_Name, Seg_Size);
rc = ND_Value_Alloc( (void **)&MHH, SM_Base->MHR, prefixed_name, Seg_Size);
if( rc != NDS_OK)
{
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to alloc a new MHH structure");
@ -671,7 +681,7 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
if( rc != SMS_OK)
{
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to lock heap \"%s\" for %s",
Prefixed_Name, Open_Mode & SMD_READ ? "reading" : "writing");
prefixed_name, Open_Mode & SMD_READ ? "reading" : "writing");
SM_Error_Print();
goto Error10;
}
@ -683,14 +693,14 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
*Heap = (SMT_Heap *)malloc( sizeof( SMT_Heap));
if( !*Heap)
{
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to allocate memory for a new opened heap \"%s\"", Prefixed_Name);
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to allocate memory for a new opened heap \"%s\"", prefixed_name);
SM_Error_Print();
rc = SMS_ERRMEM;
goto Error10;
}
( *Heap)->Name = strdup( Prefixed_Name);
( *Heap)->Name = strdup( prefixed_name);
( *Heap)->MHH = MHH;
( *Heap)->Lock_Mode = SMD_LOCK_MSK( Open_Mode);
( *Heap)->Nb_Seg = 1;
@ -698,7 +708,7 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
rc = ND_DataStruct_Value_Add( Opened_Heap_List, *Heap);
if( rc != NDS_OK)
{
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to add heap \"%s\" to the opened heap cache", Prefixed_Name);
sprintf( SM_Error_Msg, "SM_Heap_Open : unable to add heap \"%s\" to the opened heap cache", prefixed_name);
SM_Error_Print();
goto Error11;
@ -770,13 +780,15 @@ SMT_Status SM_Heap_Open_I( const char *Heap_Name, SMT_Heap **Heap, size_t Se
SMT_Status SM_Heap_IsOpen_I( const char *Heap_Name, SMT_Heap **Heap )
{
SMT_Status rc;
char prefixed_name[ SMD_NAME_SIZE];
SMT_Heap To_Find;
NDT_Node *Node_Ptr;
*Heap = NULL;
To_Find.Name = SM_Name_Prefix( Heap_Name);
To_Find.Name = prefixed_name;
SM_Name_Prefix( prefixed_name, Heap_Name);
rc = ND_Index_Node_Find( &Node_Ptr, Opened_Heap_List, NDD_INDEX_PRIMARY, &To_Find, NULL);
@ -788,6 +800,7 @@ SMT_Status SM_Heap_IsOpen_I( const char *Heap_Name, SMT_Heap **Heap )
{
if( Node_Ptr == NULL)
{
*Heap = NULL;
return( SMS_NO);
}
else
@ -1109,7 +1122,7 @@ SMT_Status SM_Heap_Lock_I ( SMT_Heap * Heap, SMT_Flags Lock_Mode, int * Locked )
*Locked = TRUE;
}
return SMS_OK;
return( SMS_OK);
}
@ -5638,17 +5651,22 @@ void SM_Error_Print ( void )
/*------------------------------------------------------------------------------*/
/* Pour préfixer un nom de heap avec le nom du contexte d'utilisation */
/* Add context prefix to heap name */
/*------------------------------------------------------------------------------*/
/* (O) Prefixed: Prefixed heap name */
/* (I) Unprefixed: Unprefixed heap name */
/*------------------------------------------------------------------------------*/
static char * SM_Name_Prefix ( const char * Name)
SMT_Status SM_Name_Prefix( char *Prefixed, const char *Unprefixed)
{
static char Prefixed [256];
if (!SM_Context || !strlen (SM_Context) || !strcmp (Name, HEAP_SYSTEM))
strcpy (Prefixed, Name);
else
sprintf (Prefixed, "%s/%s", SM_Context, Name);
return Prefixed;
if( !SM_Context || !strlen( SM_Context) || !strcmp( Unprefixed, HEAP_SYSTEM))
{
strcpy( Prefixed, Unprefixed);
}
else
{
snprintf( Prefixed, SMD_NAME_LEN, "%s/%s", SM_Context, Unprefixed);
}
return( SMS_OK);
}

View File

@ -289,7 +289,13 @@ char * SM_Lock_Status_Get (const char *, void *);
/*------------------------------------------------------------------------------*/
void SM_Error_Print (void);
/*------------------------------------------------------------------------------*/
/* Pour préfixer un nom de heap avec le nom de l'instance utilisée */
/* Add context prefix to heap name */
/*------------------------------------------------------------------------------*/
static char * SM_Name_Prefix (const char *);
/* (O) Prefixed: Prefixed heap name */
/* (I) Unprefixed: Unprefixed heap name */
/*------------------------------------------------------------------------------*/
SMT_Status SM_Name_Prefix( char *, const char *);