Geant4-11
Data Structures | Typedefs | Functions
PoPs_private.h File Reference

Go to the source code of this file.

Data Structures

struct  PoPs_s
 
struct  unitsDB_s
 

Typedefs

typedef struct PoPs_s PoPs
 
typedef struct unitsDB_s unitsDB
 

Functions

int PoPs_releasePrivate (statusMessageReporting *smr)
 
char const * unitsDB_addUnitIfNeeded (statusMessageReporting *smr, char const *unit)
 
int unitsDB_index (statusMessageReporting *smr, char const *unit)
 
char const * unitsDB_stringFromIndex (statusMessageReporting *smr, int index)
 

Typedef Documentation

◆ PoPs

typedef struct PoPs_s PoPs

Definition at line 15 of file PoPs_private.h.

◆ unitsDB

typedef struct unitsDB_s unitsDB

Definition at line 14 of file PoPs_private.h.

Function Documentation

◆ PoPs_releasePrivate()

int PoPs_releasePrivate ( statusMessageReporting smr)

Definition at line 98 of file PoPs.cc.

98 {
99
100 int i;
101
102 for( i = 0; i < popsRoot.numberOfParticles; i++ ) PoP_free( popsRoot.pops[i] );
103 smr_freeMemory( (void **) &(popsRoot.pops) );
104 popsRoot.sorted = NULL;
108 return( 0 );
109}
static int unitsDB_release(void)
Definition: PoPs.cc:687
static PoPs popsRoot
Definition: PoPs.cc:43
PoP * PoP_free(PoP *pop)
Definition: PoPs.cc:558
void * smr_freeMemory(void **p)
int allocated
Definition: PoPs_private.h:25
PoP ** pops
Definition: PoPs_private.h:26
int numberOfParticles
Definition: PoPs_private.h:24
PoP ** sorted
Definition: PoPs_private.h:27

References PoPs_s::allocated, PoPs_s::numberOfParticles, PoP_free(), PoPs_s::pops, popsRoot, smr_freeMemory(), PoPs_s::sorted, and unitsDB_release().

Referenced by PoPs_release().

◆ unitsDB_addUnitIfNeeded()

char const * unitsDB_addUnitIfNeeded ( statusMessageReporting smr,
char const *  unit 
)

Definition at line 700 of file PoPs.cc.

700 {
701
702 int i;
703
704 for( i = 0; i < unitsRoot.numberOfUnits; i++ ) {
705 if( strcmp( unit, unitsRoot.unsorted[i] ) == 0 ) return( unitsRoot.unsorted[i] );
706 }
708 int size = unitsRoot.allocated + 20;
709 char const **unsorted = (char const **) smr_malloc2( smr, size * sizeof( char * ), 0, "unsorted" );
710
711 if( unsorted == NULL ) return( NULL );
712 for( i = 0; i < unitsRoot.numberOfUnits; i++ ) unsorted[i] = unitsRoot.unsorted[i];
713 smr_freeMemory( (void **) &(unitsRoot.unsorted) );
714 unitsRoot.unsorted = unsorted;
715 unitsRoot.allocated = size;
716 }
717 if( ( unitsRoot.unsorted[unitsRoot.numberOfUnits] = smr_allocateCopyString2( smr, unit, "unitsRoot.unsorted[unitsRoot.numberOfUnits]" ) ) == NULL )
718 return( NULL );
721}
static unitsDB unitsRoot
Definition: PoPs.cc:42
#define smr_allocateCopyString2(smr, s, forItem)
#define smr_malloc2(smr, size, zero, forItem)
int allocated
Definition: PoPs_private.h:19
int numberOfUnits
Definition: PoPs_private.h:18
char const ** unsorted
Definition: PoPs_private.h:20

References unitsDB_s::allocated, unitsDB_s::numberOfUnits, smr_allocateCopyString2, smr_freeMemory(), smr_malloc2, unitsRoot, and unitsDB_s::unsorted.

Referenced by PoP_makeParticle(), and PoPs_particleLoadInfo().

◆ unitsDB_index()

int unitsDB_index ( statusMessageReporting smr,
char const *  unit 
)

Definition at line 725 of file PoPs.cc.

725 {
726
727 int i;
728
729 for( i = 0; i < unitsRoot.numberOfUnits; i++ ) {
730 if( !strcmp( unit, unitsRoot.unsorted[i] ) ) return( i );
731 }
732 return( -1 );
733}

References unitsDB_s::numberOfUnits, unitsRoot, and unitsDB_s::unsorted.

◆ unitsDB_stringFromIndex()

char const * unitsDB_stringFromIndex ( statusMessageReporting smr,
int  index 
)

Definition at line 737 of file PoPs.cc.

737 {
738
739 if( ( index < 0 ) || ( index >= unitsRoot.numberOfUnits ) ) {
740 smr_setReportError2( smr, PoPs_smr_ID, 1, "index = %d out of baounds [0 to %d)", index, unitsRoot.numberOfUnits );
741 return( NULL );
742 }
743 return( unitsRoot.unsorted[index] );
744}
int PoPs_smr_ID
Definition: PoPs.cc:35
#define smr_setReportError2(smr, libraryID, code, fmt,...)

References unitsDB_s::numberOfUnits, PoPs_smr_ID, smr_setReportError2, unitsRoot, and unitsDB_s::unsorted.