Scippy

SCIP

Solving Constraint Integer Programs

memory.c File Reference

Detailed Description

memory allocation routines

Author
Tobias Achterberg
Gerald Gamrath
Marc Pfetsch
Jakob Witzig

Definition in file memory.c.

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <stdint.h>
#include "blockmemshell/memory.h"

Go to the source code of this file.

Macros

#define debugMessage   while( FALSE ) printf
 
#define errorMessage   printf
 
#define printErrorHeader(f, l)   printf("[%s:%d] ERROR: ", f, l)
 
#define printError   printf
 
#define warningMessage   printf
 
#define printInfo   printf
 
#define FALSE   0
 
#define TRUE   1
 
#define MAX(x, y)   ((x) >= (y) ? (x) : (y))
 
#define MIN(x, y)   ((x) <= (y) ? (x) : (y))
 
#define LONGINT_FORMAT   "lld"
 
#define MAXMEMSIZE   SIZE_MAX / 2
 
#define INLINE   inline
 
#define CHKHASH_POWER   10
 
#define CHKHASH_SIZE   (1<<CHKHASH_POWER)
 
#define CHUNKLENGTH_MIN   1024
 
#define CHUNKLENGTH_MAX   1048576
 
#define STORESIZE_MAX   8192
 
#define GARBAGE_SIZE   256
 
#define ALIGNMENT   (sizeof(FREELIST))
 
#define checkChunk(chunk)
 
#define checkChkmem(chkmem)
 
#define checkBlkmem(blkmem)
 

Typedefs

typedef struct Freelist FREELIST
 
typedef struct Chunk CHUNK
 

Functions

size_t BMSgetPointerSize_call (const void *ptr)
 
void BMSdisplayMemory_call (void)
 
void BMScheckEmptyMemory_call (void)
 
long long BMSgetMemoryUsed_call (void)
 
void * BMSallocClearMemory_call (size_t num, size_t typesize, const char *filename, int line)
 
void * BMSallocMemory_call (size_t size, const char *filename, int line)
 
void * BMSallocMemoryArray_call (size_t num, size_t typesize, const char *filename, int line)
 
void * BMSreallocMemory_call (void *ptr, size_t size, const char *filename, int line)
 
void * BMSreallocMemoryArray_call (void *ptr, size_t num, size_t typesize, const char *filename, int line)
 
void BMSclearMemory_call (void *ptr, size_t size)
 
void BMScopyMemory_call (void *ptr, const void *source, size_t size)
 
void BMSmoveMemory_call (void *ptr, const void *source, size_t size)
 
void * BMSduplicateMemory_call (const void *source, size_t size, const char *filename, int line)
 
void * BMSduplicateMemoryArray_call (const void *source, size_t num, size_t typesize, const char *filename, int line)
 
void BMSfreeMemory_call (void **ptr, const char *filename, int line)
 
void BMSfreeMemoryNull_call (void **ptr, const char *filename, int line)
 
static void alignSize (size_t *size)
 
void BMSalignMemsize (size_t *size)
 
int BMSisAligned (size_t size)
 
static int isPtrInChunk (const CHUNK *chunk, const void *ptr)
 
static CHUNKfindChunk (const BMS_CHKMEM *chkmem, const void *ptr)
 
static int isPtrInChkmem (const BMS_CHKMEM *chkmem, const void *ptr)
 
static int linkChunk (BMS_CHKMEM *chkmem, CHUNK *chunk, long long *memsize)
 
static void unlinkChunk (CHUNK *chunk)
 
static void linkEagerChunk (BMS_CHKMEM *chkmem, CHUNK *chunk)
 
static void unlinkEagerChunk (CHUNK *chunk)
 
static int createChunk (BMS_CHKMEM *chkmem, long long *memsize)
 
static void destroyChunk (CHUNK *chunk, long long *memsize)
 
static void freeChunk (CHUNK *chunk, long long *memsize)
 
static void * allocChunkElement (CHUNK *chunk)
 
static void freeChunkElement (CHUNK *chunk, void *ptr)
 
static BMS_CHKMEMcreateChkmem (int size, int initchunksize, int garbagefactor, long long *memsize)
 
static void clearChkmem (BMS_CHKMEM *chkmem, long long *memsize)
 
static void destroyChkmem (BMS_CHKMEM **chkmem, long long *memsize)
 
static void * allocChkmemElement (BMS_CHKMEM *chkmem, long long *memsize)
 
static void garbagecollectChkmem (BMS_CHKMEM *chkmem, long long *memsize)
 
static void freeChkmemElement (BMS_CHKMEM *chkmem, void *ptr, long long *memsize, const char *filename, int line)
 
BMS_CHKMEMBMScreateChunkMemory_call (size_t size, int initchunksize, int garbagefactor, const char *filename, int line)
 
void BMSclearChunkMemory_call (BMS_CHKMEM *chkmem, const char *filename, int line)
 
void BMSdestroyChunkMemory_call (BMS_CHKMEM **chkmem, const char *filename, int line)
 
void * BMSallocChunkMemory_call (BMS_CHKMEM *chkmem, size_t size, const char *filename, int line)
 
void * BMSduplicateChunkMemory_call (BMS_CHKMEM *chkmem, const void *source, size_t size, const char *filename, int line)
 
void BMSfreeChunkMemory_call (BMS_CHKMEM *chkmem, void **ptr, size_t size, const char *filename, int line)
 
void BMSfreeChunkMemoryNull_call (BMS_CHKMEM *chkmem, void **ptr, size_t size, const char *filename, int line)
 
void BMSgarbagecollectChunkMemory_call (BMS_CHKMEM *chkmem)
 
long long BMSgetChunkMemoryUsed_call (const BMS_CHKMEM *chkmem)
 
static BMS_CHKMEMfindChkmem (const BMS_BLKMEM *blkmem, const void *ptr)
 
static int getHashNumber (int size)
 
BMS_BLKMEMBMScreateBlockMemory_call (int initchunksize, int garbagefactor, const char *filename, int line)
 
void BMSclearBlockMemory_call (BMS_BLKMEM *blkmem, const char *filename, int line)
 
void BMSdestroyBlockMemory_call (BMS_BLKMEM **blkmem, const char *filename, int line)
 
static INLINE void * BMSallocBlockMemory_work (BMS_BLKMEM *blkmem, size_t size, const char *filename, int line)
 
void * BMSallocBlockMemory_call (BMS_BLKMEM *blkmem, size_t size, const char *filename, int line)
 
void * BMSallocBlockMemoryArray_call (BMS_BLKMEM *blkmem, size_t num, size_t typesize, const char *filename, int line)
 
void * BMSallocClearBlockMemoryArray_call (BMS_BLKMEM *blkmem, size_t num, size_t typesize, const char *filename, int line)
 
void * BMSreallocBlockMemory_call (BMS_BLKMEM *blkmem, void *ptr, size_t oldsize, size_t newsize, const char *filename, int line)
 
void * BMSreallocBlockMemoryArray_call (BMS_BLKMEM *blkmem, void *ptr, size_t oldnum, size_t newnum, size_t typesize, const char *filename, int line)
 
void * BMSduplicateBlockMemory_call (BMS_BLKMEM *blkmem, const void *source, size_t size, const char *filename, int line)
 
void * BMSduplicateBlockMemoryArray_call (BMS_BLKMEM *blkmem, const void *source, size_t num, size_t typesize, const char *filename, int line)
 
static INLINE void BMSfreeBlockMemory_work (BMS_BLKMEM *blkmem, void **ptr, size_t size, const char *filename, int line)
 
void BMSfreeBlockMemory_call (BMS_BLKMEM *blkmem, void **ptr, size_t size, const char *filename, int line)
 
void BMSfreeBlockMemoryNull_call (BMS_BLKMEM *blkmem, void **ptr, size_t size, const char *filename, int line)
 
void BMSgarbagecollectBlockMemory_call (BMS_BLKMEM *blkmem)
 
long long BMSgetBlockMemoryAllocated_call (const BMS_BLKMEM *blkmem)
 
long long BMSgetBlockMemoryUsed_call (const BMS_BLKMEM *blkmem)
 
long long BMSgetBlockMemoryUnused_call (const BMS_BLKMEM *blkmem)
 
long long BMSgetBlockMemoryUsedMax_call (const BMS_BLKMEM *blkmem)
 
long long BMSgetBlockMemoryUnusedMax_call (const BMS_BLKMEM *blkmem)
 
long long BMSgetBlockMemoryAllocatedMax_call (const BMS_BLKMEM *blkmem)
 
size_t BMSgetBlockPointerSize_call (const BMS_BLKMEM *blkmem, const void *ptr)
 
void BMSdisplayBlockMemory_call (const BMS_BLKMEM *blkmem)
 
long long BMScheckEmptyBlockMemory_call (const BMS_BLKMEM *blkmem)
 
BMS_BUFMEMBMScreateBufferMemory_call (double arraygrowfac, int arraygrowinit, unsigned int clean, const char *filename, int line)
 
void BMSdestroyBufferMemory_call (BMS_BUFMEM **buffer, const char *filename, int line)
 
void BMSsetBufferMemoryArraygrowfac (BMS_BUFMEM *buffer, double arraygrowfac)
 
void BMSsetBufferMemoryArraygrowinit (BMS_BUFMEM *buffer, int arraygrowinit)
 
static size_t calcMemoryGrowSize (size_t initsize, SCIP_Real growfac, size_t num)
 
static INLINE void * BMSallocBufferMemory_work (BMS_BUFMEM *buffer, size_t size, const char *filename, int line)
 
void * BMSallocBufferMemory_call (BMS_BUFMEM *buffer, size_t size, const char *filename, int line)
 
void * BMSallocBufferMemoryArray_call (BMS_BUFMEM *buffer, size_t num, size_t typesize, const char *filename, int line)
 
void * BMSallocClearBufferMemoryArray_call (BMS_BUFMEM *buffer, size_t num, size_t typesize, const char *filename, int line)
 
static INLINE void * BMSreallocBufferMemory_work (BMS_BUFMEM *buffer, void *ptr, size_t size, const char *filename, int line)
 
void * BMSreallocBufferMemory_call (BMS_BUFMEM *buffer, void *ptr, size_t size, const char *filename, int line)
 
void * BMSreallocBufferMemoryArray_call (BMS_BUFMEM *buffer, void *ptr, size_t num, size_t typesize, const char *filename, int line)
 
void * BMSduplicateBufferMemory_call (BMS_BUFMEM *buffer, const void *source, size_t size, const char *filename, int line)
 
void * BMSduplicateBufferMemoryArray_call (BMS_BUFMEM *buffer, const void *source, size_t num, size_t typesize, const char *filename, int line)
 
static INLINE void BMSfreeBufferMemory_work (BMS_BUFMEM *buffer, void **ptr, const char *filename, int line)
 
void BMSfreeBufferMemory_call (BMS_BUFMEM *buffer, void **ptr, const char *filename, int line)
 
void BMSfreeBufferMemoryNull_call (BMS_BUFMEM *buffer, void **ptr, const char *filename, int line)
 
size_t BMSgetNUsedBufferMemory (BMS_BUFMEM *buffer)
 
long long BMSgetBufferMemoryUsed (const BMS_BUFMEM *buffer)
 
void BMSprintBufferMemory (BMS_BUFMEM *buffer)
 

Macro Definition Documentation

◆ debugMessage

◆ errorMessage

#define errorMessage   printf

Definition at line 60 of file memory.c.

Referenced by BMScheckEmptyBlockMemory_call(), and garbagecollectChkmem().

◆ printErrorHeader

◆ printError

◆ warningMessage

#define warningMessage   printf

Definition at line 65 of file memory.c.

Referenced by BMSfreeBufferMemory_work().

◆ printInfo

#define printInfo   printf

◆ FALSE

#define FALSE   0

◆ TRUE

#define TRUE   1

Definition at line 71 of file memory.c.

Referenced by BMSallocBufferMemory_work(), and linkChunk().

◆ MAX

◆ MIN

#define MIN (   x,
 
)    ((x) <= (y) ? (x) : (y))

Definition at line 75 of file memory.c.

Referenced by addConcaveEstimatorBivariate(), addConcaveEstimatorMultivariate(), addConcaveEstimatorUnivariate(), addConflictBinvar(), addIntervalGradientEstimator(), addLinearization(), addLinearizationCuts(), addUserEstimator(), adjustStorageSize(), aggregation(), analyzeEnergyRequirement(), applyFixings(), applyVbounds(), BMSreallocBlockMemory_call(), BMSreallocBlockMemoryArray_call(), branchBalancedCardinality(), calcCliquePartitionGreedy(), calcNodeLimit(), calcPscostQuot(), calcScore(), calcShiftVal(), calcTwoRowBnds(), calculateBounds(), checkArraySizesGLS(), checkArraySizesHeur(), checkCons(), checkCurvature(), checkFactorable(), checkFixedVariables(), checkNumerics(), checkRedundancySide(), chooseDoubleVar(), collectBinaryCliqueData(), collectBinaryVars(), collectBranchingCands(), collectDataTTEF(), collectIntVars(), collectMaxactVar(), collectNonBinaryImplicationData(), collectNonBinaryVBoundData(), collectThetaSubtree(), computeCoreWithInterval(), computeFieldWidth(), computeFixingOrder(), computeIntegerVariableBounds(), computeInteriorPoint(), computeReferencePointGauge(), computeReferencePointProjection(), computeViolation(), conflictAnalyze(), conflictCreateReconvergenceConss(), conflictInsertConflictset(), conflictMarkBoundCheckPresence(), conflictsetAddBound(), conflictsetAddBounds(), conflictsetCalcInsertDepth(), conflictstoreEnsureMem(), consCapacityConstraintsFinder(), consCheckRedundancy(), consdataGetActivity(), consdataUpdateLinearActivity(), coretimesUpdateLb(), createChunk(), createCoreProfile(), createCoverCuts(), createCoverCutsTimepoint(), createCoveringProblem(), createDisjuctiveCons(), createNlRow(), createSelectedSortedEventpointsSol(), createSubproblem(), cutGenerationHeuristic(), cutpoolDelCut(), determineBound(), determineLimits(), determineMaxDistance(), determineVariableFixings(), dualWeightsTightening(), enforceConflictgraph(), enforceConstraint(), ensureMemorySize(), ensurePartialsolsSize(), evalMin(), execRelpscost(), exprgraphUpdateVarNodeBounds(), exprUnconvertPolynomial(), findDominancePairs(), fixAndPropagate(), fixDiscreteVars(), fixInterdiction(), freeThreadPool(), generateCloseCutPoint(), generateConvexConcaveUnderestimator(), generateCut(), generateCutLTIcomputeCoefs(), generateCutSol(), generateDisjCutSOS1(), generateOrthogonal_lx_ly_Underestimator(), generateOrthogonal_lx_uy_Underestimator(), generateSparseCut(), generateUnderestimatorParallelYFacets(), getBounddist(), getBranchingDecisionStrongbranchSOS1(), getDiveBdChgsSOS1conflictgraph(), getDiveBdChgsSOS1constraints(), getFlowCover(), getImpliedBounds(), getIterationsLeft(), getMinFeas(), getRelDistance(), getVectorOfWeights(), getZiValue(), GUBsetCalcCliquePartition(), handleCycle(), hessLagAddExprtree(), hessLagSparsitySetNzFlagForExprtree(), improvePoint(), initConflictstore(), initSepaData(), insertSortedRootNeighbors(), insertZerolist(), isLbBetter(), isUbBetter(), lpGetResolveItlim(), multihashResize(), nlrowRemoveFixedLinearCoefs(), nlrowRemoveFixedQuadVars(), nodeGetUctScore(), nodepairqueueCreate(), normalizeCumulativeCondition(), optimize(), paramsetSetSeparatingAggressive(), performFixing(), performStrongbranchWithPropagation(), perturb(), phi(), preprocessCliques(), preprocessConstraintPairs(), presolveConsEst(), presolveConsLct(), presolveDual(), presolveFindDuplicates(), presolveTryAddLinearReform(), prettifyConss(), priceAndCutLoop(), primalAddOrigSol(), primalAddSol(), primalSetCutoffbound(), primalSetUpperbound(), propagateBounds(), propagateBoundsBilinearTerm(), propagateBoundsCons(), propagateBoundsGetQuadActivity(), propagateBoundsQuadVar(), propagateCons(), propagateLbTTEF(), propagateTimetable(), propagateUbTTEF(), proposeBranchingPoint(), proposeFeasibleSolution(), readBounds(), readNonlinearExprs(), registerBranchingCandidatesCentrality(), registerBranchingCandidatesGap(), reoptSimilarity(), resolvePropagation(), resolvePropagationCoretimes(), respropCumulativeCondition(), rowAddNorms(), rowCalcIdxsAndVals(), sampleRandomPoints(), SCIP_DECL_BRANCHEXECLP(), SCIP_DECL_CONCSOLVERSYNCWRITE(), SCIP_DECL_CONSINITLP(), SCIP_DECL_CONSINITSOL(), SCIP_DECL_EXPREVAL(), SCIP_DECL_EXPRGRAPHVARADDED(), SCIP_DECL_HEUREXEC(), SCIP_DECL_NLPISETINTPAR(), SCIP_DECL_NODESELSELECT(), SCIP_DECL_PRESOLEXEC(), SCIP_DECL_QUADCONSUPGD(), SCIP_DECL_SEPAEXECLP(), SCIP_DECL_SOLVECUMULATIVE(), SCIPaddBilinMcCormick(), SCIPaddToNlpiProblemQuadratic(), SCIPanalyzeDeductionsProbing(), SCIPapplyHeurDualval(), SCIPapplyHeurSubNlp(), SCIPapplyProximity(), SCIPapplyRens(), SCIPapplyUndercover(), SCIPapplyZeroobj(), SCIPboolarrayExtend(), SCIPboolarraySetVal(), SCIPbranchGetBranchingPoint(), SCIPcalcIntegralScalar(), SCIPcolGetStrongbranch(), SCIPcolGetStrongbranches(), SCIPcolSetStrongbranchData(), SCIPcomputeGap(), SCIPconflictAddRelaxedBound(), SCIPconflictstoreGetMaxPoolSize(), SCIPconshdlrPropagate(), SCIPconshdlrSeparateLP(), SCIPcopyConcurrentSolvingStats(), SCIPdivesetUpdateStats(), SCIPevalExprtreeLocalBounds(), SCIPexprgraphGetSeparableTrees(), SCIPgetFeasibilityQuadratic(), SCIPgetTransGap(), SCIPinferVarLbCons(), SCIPinferVarLbProp(), SCIPintarrayExtend(), SCIPintarraySetVal(), SCIPintervalCos(), SCIPintervalIntersect(), SCIPintervalIsSubsetEQ(), SCIPintervalMin(), SCIPintervalMulInf(), SCIPintervalPowerScalarInverse(), SCIPintervalQuadBivar(), SCIPintervalSin(), SCIPintervalSolveBivariateQuadExpressionAllScalar(), SCIPintervalUnify(), SCIPlpGetRootObjval(), SCIPlpGetSol(), SCIPlpGetUnboundedSol(), SCIPlpiSetIntpar(), SCIPlpShrinkCols(), SCIPlpShrinkRows(), SCIPlpSolveAndEval(), SCIPnlpiOracleGetJacobianSparsity(), SCIPnlrowCreate(), SCIPnlrowGetNLPFeasibility(), SCIPnlrowGetPseudoFeasibility(), SCIPnlrowGetSolActivity(), SCIPnlrowGetSolFeasibility(), SCIPnodeAddBoundinfer(), SCIPnodeCutoff(), SCIPnodeFocus(), SCIPnodePropagateAgain(), SCIPparamSetReal(), SCIPperformGenericDivingAlgorithm(), SCIPprimalUpdateObjlimit(), SCIPprimalUpdateObjoffset(), SCIPprobUpdateDualbound(), SCIPpropagateProbing(), SCIPptrarrayExtend(), SCIPptrarraySetVal(), SCIPrealarrayExtend(), SCIPrealarraySetVal(), SCIPrealToRational(), SCIPreoptCheckCutoff(), SCIPresolveSolHeurSubNlp(), SCIProwCalcIntegralScalar(), SCIProwCalcProbability(), SCIProwGetLPActivity(), SCIProwGetLPFeasibility(), SCIProwGetNLPFeasibility(), SCIProwGetObjParallelism(), SCIProwGetPseudoActivity(), SCIProwGetPseudoFeasibility(), SCIProwGetRelaxFeasibility(), SCIProwGetSolActivity(), SCIProwGetSolFeasibility(), SCIPselectVarPseudoStrongBranching(), SCIPselectVarStrongBranching(), SCIPsetFeastol(), SCIPsetGetDebugSolData(), SCIPsetModifiedDefaultSettingsIpopt(), SCIPsolve(), SCIPsolveCIP(), SCIPsolveParallel(), SCIPstoreSolutionGap(), SCIPsyncdataSetSyncFreq(), SCIPsyncdataSetUpperbound(), SCIPtightenVarLb(), SCIPtightenVarLbGlobal(), SCIPtreeBranchVar(), SCIPtreeBranchVarNary(), SCIPtreeCalcChildEstimate(), SCIPtreeGetLowerbound(), SCIPvarChgLbGlobal(), SCIPvarChgLbLocal(), SCIPvarGetAvgSol(), SCIPvarGetMinPseudocostScore(), SCIPvarGetMultaggrUbGlobal(), SCIPvarGetMultaggrUbLocal(), SCIPvarIsBinary(), SCIPvarIsPscostRelerrorReliable(), SCIPvarRemoveCliquesImplicsVbs(), SCIPvboundsAdd(), searchEcAggrWithCliques(), selectInitialVariable(), selectNextVariable(), selectShifting(), selectVarMultAggrBranching(), separateCons(), separateCuts(), separateGLS(), separateHeur(), separatePoint(), separateSequLiftedMinimalCoverInequality(), sepastoreIsBdchgApplicable(), sequentialUpAndDownLifting(), sequentialUpAndDownLiftingGUB(), setupSubScip(), solveAndEvalSubscip(), solveComponent(), solveDerivativeEquation(), solveNlp(), solveNLP(), solveNode(), solveSubMIP(), solveSubNLP(), solveSubproblem(), solveSubscip(), sortVariables(), tarjan(), tightenCoefs(), tightenLbTTEF(), tightenUbTTEF(), tightenVarsBoundsSOS1(), transformDualredsToBounddisjunction(), transformValue(), turnoffNodeSelector(), updateEstimate(), varAddTransitiveBinaryClosureImplic(), varAddTransitiveImplic(), varProcessChgLbLocal(), varProcessChgUbLocal(), and varUpdateAggregationBounds().

◆ LONGINT_FORMAT

#define LONGINT_FORMAT   "lld"

Definition at line 82 of file memory.c.

Referenced by BMScheckEmptyBlockMemory_call(), and BMSdisplayBlockMemory_call().

◆ MAXMEMSIZE

◆ INLINE

◆ CHKHASH_POWER

#define CHKHASH_POWER   10

power for size of chunk block hash table

Definition at line 648 of file memory.c.

Referenced by getHashNumber().

◆ CHKHASH_SIZE

#define CHKHASH_SIZE   (1<<CHKHASH_POWER)

◆ CHUNKLENGTH_MIN

#define CHUNKLENGTH_MIN   1024

minimal size of a chunk (in bytes)

Definition at line 676 of file memory.c.

Referenced by createChunk().

◆ CHUNKLENGTH_MAX

#define CHUNKLENGTH_MAX   1048576

maximal size of a chunk (in bytes)

Definition at line 677 of file memory.c.

Referenced by createChunk().

◆ STORESIZE_MAX

#define STORESIZE_MAX   8192

maximal number of elements in one chunk

Definition at line 678 of file memory.c.

Referenced by createChunk().

◆ GARBAGE_SIZE

#define GARBAGE_SIZE   256

size of lazy free list to start garbage collection

Definition at line 679 of file memory.c.

Referenced by freeChkmemElement().

◆ ALIGNMENT

#define ALIGNMENT   (sizeof(FREELIST))

minimal alignment of chunks

Definition at line 680 of file memory.c.

Referenced by alignSize(), BMSalignMemsize(), and BMSisAligned().

◆ checkChunk

#define checkChunk (   chunk)

Definition at line 925 of file memory.c.

Referenced by allocChunkElement(), freeChunkElement(), and isPtrInChkmem().

◆ checkChkmem

◆ checkBlkmem

Typedef Documentation

◆ FREELIST

typedef struct Freelist FREELIST

linked list of free memory elements

Definition at line 682 of file memory.c.

◆ CHUNK

typedef struct Chunk CHUNK

chunk of memory elements

Definition at line 683 of file memory.c.

Function Documentation

◆ BMSgetPointerSize_call()

size_t BMSgetPointerSize_call ( const void *  ptr)

returns the size of an allocated memory element

Parameters
ptrpointer to allocated memory

Definition at line 281 of file memory.c.

◆ BMSdisplayMemory_call()

void BMSdisplayMemory_call ( void  )

outputs information about currently allocated memory to the screen

Definition at line 289 of file memory.c.

References printInfo.

◆ BMScheckEmptyMemory_call()

void BMScheckEmptyMemory_call ( void  )

displays a warning message on the screen, if allocated memory exists

Definition at line 299 of file memory.c.

References printInfo.

◆ BMSgetMemoryUsed_call()

long long BMSgetMemoryUsed_call ( void  )

returns total number of allocated bytes

Definition at line 309 of file memory.c.

◆ BMSallocClearMemory_call()

void* BMSallocClearMemory_call ( size_t  num,
size_t  typesize,
const char *  filename,
int  line 
)

allocates array and initializes it with 0; returns NULL if memory allocation failed

Parameters
numnumber of memory element to allocate
typesizesize of one memory element to allocate
filenamesource file where the allocation is performed
lineline number in source file where the allocation is performed

Definition at line 319 of file memory.c.

References debugMessage, MAX, MAXMEMSIZE, NULL, printError, and printErrorHeader.

◆ BMSallocMemory_call()

void* BMSallocMemory_call ( size_t  size,
const char *  filename,
int  line 
)

allocates memory; returns NULL if memory allocation failed

Parameters
sizesize of memory element to allocate
filenamesource file where the allocation is performed
lineline number in source file where the allocation is performed

Definition at line 358 of file memory.c.

References debugMessage, MAX, MAXMEMSIZE, NULL, printError, and printErrorHeader.

Referenced by BMSduplicateMemory_call().

◆ BMSallocMemoryArray_call()

void* BMSallocMemoryArray_call ( size_t  num,
size_t  typesize,
const char *  filename,
int  line 
)

allocates array; returns NULL if memory allocation failed

Parameters
numnumber of components of array to allocate
typesizesize of each component
filenamesource file where the allocation is performed
lineline number in source file where the allocation is performed

Definition at line 394 of file memory.c.

References debugMessage, MAX, MAXMEMSIZE, NULL, printError, and printErrorHeader.

Referenced by BMSduplicateMemoryArray_call().

◆ BMSreallocMemory_call()

void* BMSreallocMemory_call ( void *  ptr,
size_t  size,
const char *  filename,
int  line 
)

allocates memory; returns NULL if memory allocation failed

Parameters
ptrpointer to memory to reallocate
sizenew size of memory element
filenamesource file where the reallocation is performed
lineline number in source file where the reallocation is performed

Definition at line 434 of file memory.c.

References MAX, MAXMEMSIZE, NULL, printError, and printErrorHeader.

◆ BMSreallocMemoryArray_call()

void* BMSreallocMemoryArray_call ( void *  ptr,
size_t  num,
size_t  typesize,
const char *  filename,
int  line 
)

reallocates array; returns NULL if memory allocation failed

Parameters
ptrpointer to memory to reallocate
numnumber of components of array to allocate
typesizesize of each component
filenamesource file where the reallocation is performed
lineline number in source file where the reallocation is performed

Definition at line 474 of file memory.c.

References MAX, MAXMEMSIZE, NULL, printError, and printErrorHeader.

◆ BMSclearMemory_call()

void BMSclearMemory_call ( void *  ptr,
size_t  size 
)

clears a memory element (i.e. fills it with zeros)

Parameters
ptrpointer to memory element
sizesize of memory element

Definition at line 517 of file memory.c.

References NULL.

◆ BMScopyMemory_call()

void BMScopyMemory_call ( void *  ptr,
const void *  source,
size_t  size 
)

copies the contents of one memory element into another memory element

Parameters
ptrpointer to target memory element
sourcepointer to source memory element
sizesize of memory element to copy

Definition at line 530 of file memory.c.

References NULL.

Referenced by BMSduplicateMemory_call(), and BMSduplicateMemoryArray_call().

◆ BMSmoveMemory_call()

void BMSmoveMemory_call ( void *  ptr,
const void *  source,
size_t  size 
)

moves the contents of one memory element into another memory element, should be used if both elements overlap, otherwise BMScopyMemory is faster

Parameters
ptrpointer to target memory element
sourcepointer to source memory element
sizesize of memory element to copy

Definition at line 547 of file memory.c.

References NULL.

◆ BMSduplicateMemory_call()

void* BMSduplicateMemory_call ( const void *  source,
size_t  size,
const char *  filename,
int  line 
)

allocates memory and copies the contents of the given memory element into the new memory element

Parameters
sourcepointer to source memory element
sizesize of memory element to copy
filenamesource file where the duplication is performed
lineline number in source file where the duplication is performed

Definition at line 562 of file memory.c.

References BMSallocMemory_call(), BMScopyMemory_call(), and NULL.

◆ BMSduplicateMemoryArray_call()

void* BMSduplicateMemoryArray_call ( const void *  source,
size_t  num,
size_t  typesize,
const char *  filename,
int  line 
)

allocates array and copies the contents of the given source array into the new array

Parameters
sourcepointer to source memory element
numnumber of components of array to allocate
typesizesize of each component
filenamesource file where the duplication is performed
lineline number in source file where the duplication is performed

Definition at line 581 of file memory.c.

References BMSallocMemoryArray_call(), BMScopyMemory_call(), and NULL.

◆ BMSfreeMemory_call()

void BMSfreeMemory_call ( void **  ptr,
const char *  filename,
int  line 
)

frees an allocated memory element and sets pointer to NULL

Parameters
ptrpointer to pointer to memory element
filenamesource file where the deallocation is performed
lineline number in source file where the deallocation is performed

Definition at line 601 of file memory.c.

References NULL, printError, and printErrorHeader.

◆ BMSfreeMemoryNull_call()

void BMSfreeMemoryNull_call ( void **  ptr,
const char *  filename,
int  line 
)

frees an allocated memory element if pointer is not NULL and sets pointer to NULL

Parameters
ptrpointer to pointer to memory element
filenamesource file where the deallocation is performed
lineline number in source file where the deallocation is performed

Definition at line 624 of file memory.c.

References NULL.

◆ alignSize()

static void alignSize ( size_t *  size)
static

aligns the given byte size corresponding to the minimal alignment

Parameters
sizepointer to the size to align

Definition at line 734 of file memory.c.

References ALIGNMENT.

Referenced by BMSalignMemsize(), BMSallocBlockMemory_work(), BMScreateChunkMemory_call(), BMSfreeBlockMemory_work(), and BMSreallocBlockMemory_call().

◆ BMSalignMemsize()

void BMSalignMemsize ( size_t *  size)

aligns the given byte size corresponding to the minimal alignment for chunk and block memory

Parameters
sizepointer to the size to align

Definition at line 745 of file memory.c.

References ALIGNMENT, and alignSize().

◆ BMSisAligned()

int BMSisAligned ( size_t  size)

checks whether the given size meets the alignment conditions for chunk and block memory

Parameters
sizesize to check for alignment

Definition at line 754 of file memory.c.

References ALIGNMENT.

Referenced by createChkmem(), createChunk(), and getHashNumber().

◆ isPtrInChunk()

static int isPtrInChunk ( const CHUNK chunk,
const void *  ptr 
)
static

checks, if the given pointer belongs to the given chunk

Parameters
chunkmemory chunk
ptrpointer

Definition at line 765 of file memory.c.

References NULL.

Referenced by freeChunkElement(), and isPtrInChkmem().

◆ findChunk()

static CHUNK* findChunk ( const BMS_CHKMEM chkmem,
const void *  ptr 
)
static

given a pointer, finds the chunk this pointer points to in the chunk array of the given chunk block; binary search is used; returns NULL if the pointer does not belong to the chunk block

Parameters
chkmemchunk block
ptrpointer

Definition at line 782 of file memory.c.

References NULL.

Referenced by garbagecollectChkmem(), and isPtrInChkmem().

◆ isPtrInChkmem()

static int isPtrInChkmem ( const BMS_CHKMEM chkmem,
const void *  ptr 
)
static

checks, if a pointer belongs to a chunk of the given chunk block

Parameters
chkmemchunk block
ptrpointer

Definition at line 818 of file memory.c.

References checkChkmem, checkChunk, findChunk(), isPtrInChunk(), and NULL.

Referenced by findChkmem(), and freeChkmemElement().

◆ linkChunk()

static int linkChunk ( BMS_CHKMEM chkmem,
CHUNK chunk,
long long *  memsize 
)
static

links chunk to the block's chunk array, sort it by store pointer; returns TRUE if successful, FALSE otherwise

Parameters
chkmemchunk block
chunkmemory chunk
memsizepointer to total size of allocated memory (or NULL)

Definition at line 934 of file memory.c.

References BMSreallocMemoryArray, debugMessage, FALSE, NULL, and TRUE.

Referenced by createChunk().

◆ unlinkChunk()

static void unlinkChunk ( CHUNK chunk)
static

unlinks chunk from the chunk block's chunk list

Parameters
chunkmemory chunk

Definition at line 1011 of file memory.c.

References debugMessage, and NULL.

Referenced by freeChunk().

◆ linkEagerChunk()

static void linkEagerChunk ( BMS_CHKMEM chkmem,
CHUNK chunk 
)
static

links chunk to the chunk block's eager chunk list

Parameters
chkmemchunk block
chunkmemory chunk

Definition at line 1044 of file memory.c.

References NULL.

Referenced by freeChunkElement().

◆ unlinkEagerChunk()

static void unlinkEagerChunk ( CHUNK chunk)
static

unlinks chunk from the chunk block's eager chunk list

Parameters
chunkmemory chunk

Definition at line 1065 of file memory.c.

References NULL.

Referenced by allocChunkElement(), and freeChunk().

◆ createChunk()

static int createChunk ( BMS_CHKMEM chkmem,
long long *  memsize 
)
static

creates a new memory chunk in the given chunk block and adds memory elements to the lazy free list; returns TRUE if successful, FALSE otherwise

Parameters
chkmemchunk block
memsizepointer to total size of allocated memory (or NULL)

Definition at line 1090 of file memory.c.

References BMSallocMemorySize, BMSisAligned(), checkChkmem, CHUNKLENGTH_MAX, CHUNKLENGTH_MIN, debugMessage, FALSE, linkChunk(), MAX, MAXMEMSIZE, MIN, NULL, and STORESIZE_MAX.

Referenced by allocChkmemElement().

◆ destroyChunk()

static void destroyChunk ( CHUNK chunk,
long long *  memsize 
)
static

destroys a chunk without updating the chunk lists

Parameters
chunkmemory chunk
memsizepointer to total size of allocated memory (or NULL)

Definition at line 1166 of file memory.c.

References BMSfreeMemory, debugMessage, and NULL.

Referenced by clearChkmem(), and freeChunk().

◆ freeChunk()

static void freeChunk ( CHUNK chunk,
long long *  memsize 
)
static

removes a completely unused chunk, i.e. a chunk with all elements in the eager free list

Parameters
chunkmemory chunk
memsizepointer to total size of allocated memory (or NULL)

Definition at line 1184 of file memory.c.

References debugMessage, destroyChunk(), NULL, unlinkChunk(), and unlinkEagerChunk().

Referenced by garbagecollectChkmem().

◆ allocChunkElement()

static void* allocChunkElement ( CHUNK chunk)
static

returns an element of the eager free list and removes it from the list

Parameters
chunkmemory chunk

Definition at line 1215 of file memory.c.

References checkChunk, debugMessage, NULL, and unlinkEagerChunk().

Referenced by allocChkmemElement().

◆ freeChunkElement()

static void freeChunkElement ( CHUNK chunk,
void *  ptr 
)
static

puts given pointer into the eager free list and adds the chunk to the eager list of its chunk block, if necessary

Parameters
chunkmemory chunk
ptrpointer

Definition at line 1252 of file memory.c.

References checkChunk, debugMessage, isPtrInChunk(), linkEagerChunk(), and NULL.

Referenced by garbagecollectChkmem().

◆ createChkmem()

static BMS_CHKMEM* createChkmem ( int  size,
int  initchunksize,
int  garbagefactor,
long long *  memsize 
)
static

creates a new chunk block data structure

Parameters
sizeelement size of the chunk block
initchunksizenumber of elements in the first chunk of the chunk block
garbagefactorgarbage collector is called, if at least garbagefactor * avg. chunksize elements are free (-1: disable garbage collection)
memsizepointer to total size of allocated memory (or NULL)

Definition at line 1281 of file memory.c.

References BMSallocMemory, BMSisAligned(), and NULL.

Referenced by BMSallocBlockMemory_work(), and BMScreateChunkMemory_call().

◆ clearChkmem()

static void clearChkmem ( BMS_CHKMEM chkmem,
long long *  memsize 
)
static

destroys all chunks of the chunk block, but keeps the chunk block header structure

Parameters
chkmemchunk block
memsizepointer to total size of allocated memory (or NULL)

Definition at line 1326 of file memory.c.

References destroyChunk(), and NULL.

Referenced by BMSclearChunkMemory_call(), destroyChkmem(), and garbagecollectChkmem().

◆ destroyChkmem()

static void destroyChkmem ( BMS_CHKMEM **  chkmem,
long long *  memsize 
)
static

deletes chunk block and frees all associated memory chunks

Parameters
chkmempointer to chunk block
memsizepointer to total size of allocated memory (or NULL)

Definition at line 1350 of file memory.c.

References BMSfreeMemory, BMSfreeMemoryArrayNull, clearChkmem(), and NULL.

Referenced by BMSclearBlockMemory_call(), BMSdestroyChunkMemory_call(), and BMSgarbagecollectBlockMemory_call().

◆ allocChkmemElement()

static void* allocChkmemElement ( BMS_CHKMEM chkmem,
long long *  memsize 
)
static

allocates a new memory element from the chunk block

Parameters
chkmemchunk block
memsizepointer to total size of allocated memory (or NULL)

Definition at line 1373 of file memory.c.

References allocChunkElement(), checkChkmem, createChunk(), and NULL.

Referenced by BMSallocBlockMemory_work(), and BMSallocChunkMemory_call().

◆ garbagecollectChkmem()

static void garbagecollectChkmem ( BMS_CHKMEM chkmem,
long long *  memsize 
)
static

sorts the lazy free list of the chunk block into the eager free lists of the chunks, and removes completely unused chunks

Parameters
chkmemchunk block
memsizepointer to total size of allocated memory (or NULL)

Definition at line 1413 of file memory.c.

References checkChkmem, clearChkmem(), debugMessage, errorMessage, findChunk(), freeChunk(), freeChunkElement(), and NULL.

Referenced by BMSgarbagecollectBlockMemory_call(), BMSgarbagecollectChunkMemory_call(), and freeChkmemElement().

◆ freeChkmemElement()

static void freeChkmemElement ( BMS_CHKMEM chkmem,
void *  ptr,
long long *  memsize,
const char *  filename,
int  line 
)
static

frees a memory element and returns it to the lazy freelist of the chunk block

Parameters
chkmemchunk block
ptrmemory element
memsizepointer to total size of allocated memory (or NULL)
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 1481 of file memory.c.

References checkChkmem, GARBAGE_SIZE, garbagecollectChkmem(), isPtrInChkmem(), NULL, printError, and printErrorHeader.

Referenced by BMSfreeBlockMemory_work(), BMSfreeChunkMemory_call(), and BMSfreeChunkMemoryNull_call().

◆ BMScreateChunkMemory_call()

BMS_CHKMEM* BMScreateChunkMemory_call ( size_t  size,
int  initchunksize,
int  garbagefactor,
const char *  filename,
int  line 
)

creates a new chunk block data structure

Parameters
sizeelement size of the chunk block
initchunksizenumber of elements in the first chunk of the chunk block
garbagefactorgarbage collector is called, if at least garbagefactor * avg. chunksize elements are free (-1: disable garbage collection)
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 1518 of file memory.c.

References alignSize(), createChkmem(), debugMessage, NULL, printError, and printErrorHeader.

◆ BMSclearChunkMemory_call()

void BMSclearChunkMemory_call ( BMS_CHKMEM chkmem,
const char *  filename,
int  line 
)

clears a chunk block data structure

Parameters
chkmemchunk block
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 1542 of file memory.c.

References clearChkmem(), debugMessage, NULL, printError, and printErrorHeader.

◆ BMSdestroyChunkMemory_call()

void BMSdestroyChunkMemory_call ( BMS_CHKMEM **  chkmem,
const char *  filename,
int  line 
)

destroys and frees a chunk block data structure

Parameters
chkmempointer to chunk block
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 1560 of file memory.c.

References debugMessage, destroyChkmem(), NULL, printError, and printErrorHeader.

◆ BMSallocChunkMemory_call()

void* BMSallocChunkMemory_call ( BMS_CHKMEM chkmem,
size_t  size,
const char *  filename,
int  line 
)

allocates a memory element of the given chunk block

Parameters
chkmemchunk block
sizesize of memory element to allocate (only needed for sanity check)
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 1580 of file memory.c.

References allocChkmemElement(), checkChkmem, debugMessage, NULL, printError, and printErrorHeader.

Referenced by BMSduplicateChunkMemory_call().

◆ BMSduplicateChunkMemory_call()

void* BMSduplicateChunkMemory_call ( BMS_CHKMEM chkmem,
const void *  source,
size_t  size,
const char *  filename,
int  line 
)

duplicates a given memory element by allocating a new element of the same chunk block and copying the data

Parameters
chkmemchunk block
sourcesource memory element
sizesize of memory element to allocate (only needed for sanity check)
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 1607 of file memory.c.

References BMSallocChunkMemory_call(), BMScopyMemorySize, and NULL.

◆ BMSfreeChunkMemory_call()

void BMSfreeChunkMemory_call ( BMS_CHKMEM chkmem,
void **  ptr,
size_t  size,
const char *  filename,
int  line 
)

frees a memory element of the given chunk block and sets pointer to NULL

Parameters
chkmemchunk block
ptrpointer to pointer to memory element to free
sizesize of memory element to allocate (only needed for sanity check)
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 1629 of file memory.c.

References checkChkmem, debugMessage, freeChkmemElement(), NULL, printError, and printErrorHeader.

◆ BMSfreeChunkMemoryNull_call()

void BMSfreeChunkMemoryNull_call ( BMS_CHKMEM chkmem,
void **  ptr,
size_t  size,
const char *  filename,
int  line 
)

frees a memory element of the given chunk block if pointer is not NULL and sets pointer to NULL

Parameters
chkmemchunk block
ptrpointer to pointer to memory element to free
sizesize of memory element to allocate (only needed for sanity check)
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 1658 of file memory.c.

References checkChkmem, debugMessage, freeChkmemElement(), and NULL.

◆ BMSgarbagecollectChunkMemory_call()

void BMSgarbagecollectChunkMemory_call ( BMS_CHKMEM chkmem)

calls garbage collection of chunk block and frees chunks without allocated memory elements

Parameters
chkmemchunk block

Definition at line 1682 of file memory.c.

References debugMessage, garbagecollectChkmem(), and NULL.

◆ BMSgetChunkMemoryUsed_call()

long long BMSgetChunkMemoryUsed_call ( const BMS_CHKMEM chkmem)

returns the number of allocated bytes in the chunk block

Parameters
chkmemchunk block

Definition at line 1692 of file memory.c.

References checkBlkmem, checkChkmem, CHKHASH_SIZE, and NULL.

◆ findChkmem()

static BMS_CHKMEM* findChkmem ( const BMS_BLKMEM blkmem,
const void *  ptr 
)
static

finds the chunk block, to whick the given pointer belongs to

This could be done by selecting the chunk block of the corresponding element size, but in a case of an error (free gives an incorrect element size), we want to identify and output the correct element size.

Parameters
blkmemblock memory
ptrmemory element to search

Definition at line 1757 of file memory.c.

References CHKHASH_SIZE, isPtrInChkmem(), and NULL.

Referenced by BMSgetBlockPointerSize_call().

◆ getHashNumber()

static int getHashNumber ( int  size)
static

calculates hash number of memory size

Parameters
sizeelement size

Definition at line 1780 of file memory.c.

References BMSisAligned(), and CHKHASH_POWER.

Referenced by BMSallocBlockMemory_work(), and BMSfreeBlockMemory_work().

◆ BMScreateBlockMemory_call()

BMS_BLKMEM* BMScreateBlockMemory_call ( int  initchunksize,
int  garbagefactor,
const char *  filename,
int  line 
)

creates a block memory allocation data structure

Parameters
initchunksizenumber of elements in the first chunk of each chunk block
garbagefactorgarbage collector is called, if at least garbagefactor * avg. chunksize elements are free (-1: disable garbage collection)
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 1791 of file memory.c.

References BMSallocMemory, CHKHASH_SIZE, NULL, printError, and printErrorHeader.

◆ BMSclearBlockMemory_call()

void BMSclearBlockMemory_call ( BMS_BLKMEM blkmem,
const char *  filename,
int  line 
)

frees all chunk blocks in the block memory

Parameters
blkmemblock memory
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 1825 of file memory.c.

References CHKHASH_SIZE, destroyChkmem(), NULL, printError, and printErrorHeader.

Referenced by BMSdestroyBlockMemory_call().

◆ BMSdestroyBlockMemory_call()

void BMSdestroyBlockMemory_call ( BMS_BLKMEM **  blkmem,
const char *  filename,
int  line 
)

clears and deletes block memory

Parameters
blkmempointer to block memory
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 1859 of file memory.c.

References BMSclearBlockMemory_call(), BMSfreeMemory, INLINE, NULL, printError, and printErrorHeader.

◆ BMSallocBlockMemory_work()

static INLINE void* BMSallocBlockMemory_work ( BMS_BLKMEM blkmem,
size_t  size,
const char *  filename,
int  line 
)
static

work for allocating memory in the block memory pool

Parameters
blkmemblock memory
sizesize of memory element to allocate
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 1882 of file memory.c.

References alignSize(), allocChkmemElement(), BMSduplicateMemoryArray, checkBlkmem, createChkmem(), debugMessage, getHashNumber(), MAX, NULL, printError, and printErrorHeader.

Referenced by BMSallocBlockMemory_call(), and BMSallocBlockMemoryArray_call().

◆ BMSallocBlockMemory_call()

void* BMSallocBlockMemory_call ( BMS_BLKMEM blkmem,
size_t  size,
const char *  filename,
int  line 
)

allocates memory in the block memory pool

Parameters
blkmemblock memory
sizesize of memory element to allocate
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 1945 of file memory.c.

References BMSallocBlockMemory_work(), MAXMEMSIZE, NULL, printError, and printErrorHeader.

Referenced by BMSduplicateBlockMemory_call(), and BMSreallocBlockMemory_call().

◆ BMSallocBlockMemoryArray_call()

void* BMSallocBlockMemoryArray_call ( BMS_BLKMEM blkmem,
size_t  num,
size_t  typesize,
const char *  filename,
int  line 
)

allocates array in the block memory pool

Parameters
blkmemblock memory
numsize of array to be allocated
typesizesize of each component
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 1965 of file memory.c.

References BMSallocBlockMemory_work(), MAXMEMSIZE, NULL, printError, and printErrorHeader.

Referenced by BMSallocClearBlockMemoryArray_call(), BMSduplicateBlockMemoryArray_call(), and BMSreallocBlockMemoryArray_call().

◆ BMSallocClearBlockMemoryArray_call()

void* BMSallocClearBlockMemoryArray_call ( BMS_BLKMEM blkmem,
size_t  num,
size_t  typesize,
const char *  filename,
int  line 
)

allocates array in the block memory pool and clears it

Parameters
blkmemblock memory
numsize of array to be allocated
typesizesize of each component
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 1986 of file memory.c.

References BMSallocBlockMemoryArray_call(), BMSclearMemorySize, and NULL.

◆ BMSreallocBlockMemory_call()

void* BMSreallocBlockMemory_call ( BMS_BLKMEM blkmem,
void *  ptr,
size_t  oldsize,
size_t  newsize,
const char *  filename,
int  line 
)

resizes memory element in the block memory pool and copies the data

Parameters
blkmemblock memory
ptrmemory element to reallocated
oldsizeold size of memory element
newsizenew size of memory element
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 2004 of file memory.c.

References alignSize(), BMSallocBlockMemory_call(), BMScopyMemorySize, BMSfreeBlockMemory_call(), MAXMEMSIZE, MIN, NULL, printError, and printErrorHeader.

◆ BMSreallocBlockMemoryArray_call()

void* BMSreallocBlockMemoryArray_call ( BMS_BLKMEM blkmem,
void *  ptr,
size_t  oldnum,
size_t  newnum,
size_t  typesize,
const char *  filename,
int  line 
)

resizes array in the block memory pool and copies the data

Parameters
blkmemblock memory
ptrmemory element to reallocated
oldnumold size of array
newnumnew size of array
typesizesize of each component
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 2044 of file memory.c.

References BMSallocBlockMemoryArray_call(), BMScopyMemorySize, BMSfreeBlockMemory_call(), MAXMEMSIZE, MIN, NULL, printError, and printErrorHeader.

◆ BMSduplicateBlockMemory_call()

void* BMSduplicateBlockMemory_call ( BMS_BLKMEM blkmem,
const void *  source,
size_t  size,
const char *  filename,
int  line 
)

duplicates memory element in the block memory pool and copies the data

Parameters
blkmemblock memory
sourcememory element to duplicate
sizesize of memory elements
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 2083 of file memory.c.

References BMSallocBlockMemory_call(), BMScopyMemorySize, and NULL.

◆ BMSduplicateBlockMemoryArray_call()

void* BMSduplicateBlockMemoryArray_call ( BMS_BLKMEM blkmem,
const void *  source,
size_t  num,
size_t  typesize,
const char *  filename,
int  line 
)

duplicates array in the block memory pool and copies the data

Parameters
blkmemblock memory
sourcememory element to duplicate
numsize of array to be duplicated
typesizesize of each component
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 2103 of file memory.c.

References BMSallocBlockMemoryArray_call(), BMScopyMemorySize, INLINE, and NULL.

◆ BMSfreeBlockMemory_work()

static INLINE void BMSfreeBlockMemory_work ( BMS_BLKMEM blkmem,
void **  ptr,
size_t  size,
const char *  filename,
int  line 
)
static

common work for freeing block memory

Parameters
blkmemblock memory
ptrpointer to pointer to memory element to free
sizesize of memory element
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 2125 of file memory.c.

References alignSize(), checkBlkmem, debugMessage, freeChkmemElement(), getHashNumber(), MAX, NULL, printError, and printErrorHeader.

Referenced by BMSfreeBlockMemory_call(), and BMSfreeBlockMemoryNull_call().

◆ BMSfreeBlockMemory_call()

void BMSfreeBlockMemory_call ( BMS_BLKMEM blkmem,
void **  ptr,
size_t  size,
const char *  filename,
int  line 
)

frees memory element in the block memory pool and sets pointer to NULL

Parameters
blkmemblock memory
ptrpointer to pointer to memory element to free
sizesize of memory element
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 2173 of file memory.c.

References BMSfreeBlockMemory_work(), checkBlkmem, NULL, printError, and printErrorHeader.

Referenced by BMSreallocBlockMemory_call(), and BMSreallocBlockMemoryArray_call().

◆ BMSfreeBlockMemoryNull_call()

void BMSfreeBlockMemoryNull_call ( BMS_BLKMEM blkmem,
void **  ptr,
size_t  size,
const char *  filename,
int  line 
)

frees memory element in the block memory pool if pointer is not NULL and sets pointer to NULL

Parameters
blkmemblock memory
ptrpointer to pointer to memory element to free
sizesize of memory element
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 2195 of file memory.c.

References BMSfreeBlockMemory_work(), checkBlkmem, and NULL.

◆ BMSgarbagecollectBlockMemory_call()

void BMSgarbagecollectBlockMemory_call ( BMS_BLKMEM blkmem)

calls garbage collection of block memory, frees chunks without allocated memory elements, and frees chunk blocks without any chunks

Parameters
blkmemblock memory

Definition at line 2216 of file memory.c.

References checkBlkmem, CHKHASH_SIZE, destroyChkmem(), garbagecollectChkmem(), and NULL.

◆ BMSgetBlockMemoryAllocated_call()

long long BMSgetBlockMemoryAllocated_call ( const BMS_BLKMEM blkmem)

returns the number of allocated bytes in the block memory

Parameters
blkmemblock memory

Definition at line 2250 of file memory.c.

References NULL.

◆ BMSgetBlockMemoryUsed_call()

long long BMSgetBlockMemoryUsed_call ( const BMS_BLKMEM blkmem)

returns the number of used bytes in the block memory

Parameters
blkmemblock memory

Definition at line 2260 of file memory.c.

References NULL.

◆ BMSgetBlockMemoryUnused_call()

long long BMSgetBlockMemoryUnused_call ( const BMS_BLKMEM blkmem)

returns the number of allocated but not used bytes in the block memory

Parameters
blkmemblock memory

Definition at line 2270 of file memory.c.

References NULL.

◆ BMSgetBlockMemoryUsedMax_call()

long long BMSgetBlockMemoryUsedMax_call ( const BMS_BLKMEM blkmem)

returns the maximal number of used bytes in the block memory

Parameters
blkmemblock memory

Definition at line 2280 of file memory.c.

References NULL.

◆ BMSgetBlockMemoryUnusedMax_call()

long long BMSgetBlockMemoryUnusedMax_call ( const BMS_BLKMEM blkmem)

returns the maximal number of allocated but not used bytes in the block memory

Parameters
blkmemblock memory

Definition at line 2290 of file memory.c.

References NULL.

◆ BMSgetBlockMemoryAllocatedMax_call()

long long BMSgetBlockMemoryAllocatedMax_call ( const BMS_BLKMEM blkmem)

returns the maximal number of allocated bytes in the block memory

Parameters
blkmemblock memory

Definition at line 2300 of file memory.c.

References NULL.

◆ BMSgetBlockPointerSize_call()

size_t BMSgetBlockPointerSize_call ( const BMS_BLKMEM blkmem,
const void *  ptr 
)

returns the size of the given memory element; returns 0, if the element is not member of the block memory

Parameters
blkmemblock memory
ptrmemory element

Definition at line 2310 of file memory.c.

References findChkmem(), and NULL.

◆ BMSdisplayBlockMemory_call()

void BMSdisplayBlockMemory_call ( const BMS_BLKMEM blkmem)

outputs allocation diagnostics of block memory

Parameters
blkmemblock memory

Definition at line 2330 of file memory.c.

References CHKHASH_SIZE, LONGINT_FORMAT, NULL, and printInfo.

◆ BMScheckEmptyBlockMemory_call()

long long BMScheckEmptyBlockMemory_call ( const BMS_BLKMEM blkmem)

outputs error messages, if there are allocated elements in the block memory and returns number of unfreed bytes

Parameters
blkmemblock memory

Definition at line 2457 of file memory.c.

References CHKHASH_SIZE, errorMessage, LONGINT_FORMAT, and NULL.

◆ BMScreateBufferMemory_call()

BMS_BUFMEM* BMScreateBufferMemory_call ( double  arraygrowfac,
int  arraygrowinit,
unsigned int  clean,
const char *  filename,
int  line 
)

creates memory buffer storage

Parameters
arraygrowfacmemory growing factor for dynamically allocated arrays
arraygrowinitinitial size of dynamically allocated arrays
cleanshould the memory blocks in the buffer be initialized to zero?
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 2554 of file memory.c.

References BMS_BufMem::arraygrowfac, BMS_BufMem::arraygrowinit, BMSallocMemory, BMS_BufMem::clean, BMS_BufMem::data, BMS_BufMem::firstfree, BMS_BufMem::ndata, NULL, printError, printErrorHeader, BMS_BufMem::size, BMS_BufMem::totalmem, and BMS_BufMem::used.

◆ BMSdestroyBufferMemory_call()

void BMSdestroyBufferMemory_call ( BMS_BUFMEM **  buffer,
const char *  filename,
int  line 
)

destroys buffer memory

Parameters
bufferpointer to memory buffer storage
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 2590 of file memory.c.

References BMSfreeMemory, BMSfreeMemoryArrayNull, NULL, printError, and printErrorHeader.

◆ BMSsetBufferMemoryArraygrowfac()

void BMSsetBufferMemoryArraygrowfac ( BMS_BUFMEM buffer,
double  arraygrowfac 
)

set arraygrowfac

Parameters
bufferpointer to memory buffer storage
arraygrowfacmemory growing factor for dynamically allocated arrays

Definition at line 2623 of file memory.c.

References BMS_BufMem::arraygrowfac, and NULL.

Referenced by SCIP_DECL_PARAMCHGD().

◆ BMSsetBufferMemoryArraygrowinit()

void BMSsetBufferMemoryArraygrowinit ( BMS_BUFMEM buffer,
int  arraygrowinit 
)

set arraygrowinit

Parameters
bufferpointer to memory buffer storage
arraygrowinitinitial size of dynamically allocated arrays

Definition at line 2635 of file memory.c.

References BMS_BufMem::arraygrowinit, and NULL.

Referenced by SCIP_DECL_PARAMCHGD().

◆ calcMemoryGrowSize()

static size_t calcMemoryGrowSize ( size_t  initsize,
SCIP_Real  growfac,
size_t  num 
)
static

calculate memory size for dynamically allocated arrays

This function is a copy of the function in set.c in order to be able to use memory.? separately.

Parameters
initsizeinitial size of array
growfacgrowing factor of array
numminimum number of entries to store

Definition at line 2652 of file memory.c.

References INLINE, and MAX.

Referenced by BMSallocBufferMemory_work(), and BMSreallocBufferMemory_work().

◆ BMSallocBufferMemory_work()

static INLINE void* BMSallocBufferMemory_work ( BMS_BUFMEM buffer,
size_t  size,
const char *  filename,
int  line 
)
static

work for allocating the next unused buffer

Parameters
buffermemory buffer storage
sizeminimal required size of the buffer
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 2694 of file memory.c.

References BMS_BufMem::arraygrowfac, BMS_BufMem::arraygrowinit, BMSallocClearMemorySize, BMSallocMemorySize, BMSclearMemorySize, BMSreallocMemoryArray, BMSreallocMemorySize, calcMemoryGrowSize(), BMS_BufMem::clean, BMS_BufMem::data, debugMessage, FALSE, BMS_BufMem::firstfree, BMS_BufMem::ndata, NULL, printError, printErrorHeader, BMS_BufMem::size, BMS_BufMem::totalmem, TRUE, and BMS_BufMem::used.

Referenced by BMSallocBufferMemory_call(), and BMSallocBufferMemoryArray_call().

◆ BMSallocBufferMemory_call()

void* BMSallocBufferMemory_call ( BMS_BUFMEM buffer,
size_t  size,
const char *  filename,
int  line 
)

allocates the next unused buffer

Parameters
buffermemory buffer storage
sizeminimal required size of the buffer
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 2824 of file memory.c.

References BMSallocBufferMemory_work(), MAXMEMSIZE, NULL, printError, and printErrorHeader.

Referenced by BMSduplicateBufferMemory_call(), and BMSreallocBufferMemory_work().

◆ BMSallocBufferMemoryArray_call()

void* BMSallocBufferMemoryArray_call ( BMS_BUFMEM buffer,
size_t  num,
size_t  typesize,
const char *  filename,
int  line 
)

allocates the next unused buffer array

Parameters
buffermemory buffer storage
numsize of array to be allocated
typesizesize of components
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 2844 of file memory.c.

References BMSallocBufferMemory_work(), MAXMEMSIZE, NULL, printError, and printErrorHeader.

Referenced by BMSallocClearBufferMemoryArray_call(), and BMSduplicateBufferMemoryArray_call().

◆ BMSallocClearBufferMemoryArray_call()

void* BMSallocClearBufferMemoryArray_call ( BMS_BUFMEM buffer,
size_t  num,
size_t  typesize,
const char *  filename,
int  line 
)

allocates the next unused buffer and clears it

Parameters
buffermemory buffer storage
numsize of array to be allocated
typesizesize of components
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 2865 of file memory.c.

References BMSallocBufferMemoryArray_call(), BMSclearMemorySize, INLINE, and NULL.

◆ BMSreallocBufferMemory_work()

static INLINE void* BMSreallocBufferMemory_work ( BMS_BUFMEM buffer,
void *  ptr,
size_t  size,
const char *  filename,
int  line 
)
static

work for reallocating the buffer to at least the given size

Parameters
buffermemory buffer storage
ptrpointer to the allocated memory buffer
sizeminimal required size of the buffer
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 2884 of file memory.c.

References BMS_BufMem::arraygrowfac, BMS_BufMem::arraygrowinit, BMSallocBufferMemory_call(), BMSreallocMemorySize, calcMemoryGrowSize(), BMS_BufMem::clean, BMS_BufMem::data, debugMessage, BMS_BufMem::firstfree, BMS_BufMem::ndata, NULL, printError, printErrorHeader, BMS_BufMem::size, BMS_BufMem::totalmem, and BMS_BufMem::used.

Referenced by BMSreallocBufferMemory_call(), and BMSreallocBufferMemoryArray_call().

◆ BMSreallocBufferMemory_call()

void* BMSreallocBufferMemory_call ( BMS_BUFMEM buffer,
void *  ptr,
size_t  size,
const char *  filename,
int  line 
)

reallocates the buffer to at least the given size

Parameters
buffermemory buffer storage
ptrpointer to the allocated memory buffer
sizeminimal required size of the buffer
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 2956 of file memory.c.

References BMSreallocBufferMemory_work(), MAXMEMSIZE, NULL, printError, and printErrorHeader.

◆ BMSreallocBufferMemoryArray_call()

void* BMSreallocBufferMemoryArray_call ( BMS_BUFMEM buffer,
void *  ptr,
size_t  num,
size_t  typesize,
const char *  filename,
int  line 
)

reallocates an array in the buffer to at least the given size

Parameters
buffermemory buffer storage
ptrpointer to the allocated memory buffer
numsize of array to be allocated
typesizesize of components
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 2977 of file memory.c.

References BMSreallocBufferMemory_work(), MAXMEMSIZE, NULL, printError, and printErrorHeader.

◆ BMSduplicateBufferMemory_call()

void* BMSduplicateBufferMemory_call ( BMS_BUFMEM buffer,
const void *  source,
size_t  size,
const char *  filename,
int  line 
)

allocates the next unused buffer and copies the given memory into the buffer

Parameters
buffermemory buffer storage
sourcememory block to copy into the buffer
sizeminimal required size of the buffer
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 2999 of file memory.c.

References BMSallocBufferMemory_call(), BMScopyMemorySize, and NULL.

◆ BMSduplicateBufferMemoryArray_call()

void* BMSduplicateBufferMemoryArray_call ( BMS_BUFMEM buffer,
const void *  source,
size_t  num,
size_t  typesize,
const char *  filename,
int  line 
)

allocates an array in the next unused buffer and copies the given memory into the buffer

Parameters
buffermemory buffer storage
sourcememory block to copy into the buffer
numsize of array to be allocated
typesizesize of components
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 3022 of file memory.c.

References BMSallocBufferMemoryArray_call(), BMScopyMemorySize, INLINE, and NULL.

◆ BMSfreeBufferMemory_work()

static INLINE void BMSfreeBufferMemory_work ( BMS_BUFMEM buffer,
void **  ptr,
const char *  filename,
int  line 
)
static

work for freeing a buffer

Parameters
buffermemory buffer storage
ptrpointer to pointer to the allocated memory buffer
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 3047 of file memory.c.

References BMS_BufMem::clean, BMS_BufMem::data, debugMessage, FALSE, BMS_BufMem::firstfree, BMS_BufMem::ndata, NULL, printError, printErrorHeader, BMS_BufMem::size, BMS_BufMem::used, and warningMessage.

Referenced by BMSfreeBufferMemory_call(), and BMSfreeBufferMemoryNull_call().

◆ BMSfreeBufferMemory_call()

void BMSfreeBufferMemory_call ( BMS_BUFMEM buffer,
void **  ptr,
const char *  filename,
int  line 
)

frees a buffer and sets pointer to NULL

Parameters
buffermemory buffer storage
ptrpointer to pointer to the allocated memory buffer
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 3119 of file memory.c.

References BMSfreeBufferMemory_work(), BMSfreeMemory, NULL, printError, and printErrorHeader.

◆ BMSfreeBufferMemoryNull_call()

void BMSfreeBufferMemoryNull_call ( BMS_BUFMEM buffer,
void **  ptr,
const char *  filename,
int  line 
)

frees a buffer if pointer is not NULL and sets pointer to NULL

Parameters
buffermemory buffer storage
ptrpointer to pointer to the allocated memory buffer
filenamesource file of the function call
lineline number in source file of the function call

Definition at line 3142 of file memory.c.

References BMSfreeBufferMemory_work(), BMSfreeMemory, and NULL.

◆ BMSgetNUsedBufferMemory()

size_t BMSgetNUsedBufferMemory ( BMS_BUFMEM buffer)

gets number of used buffers

Parameters
buffermemory buffer storage

Definition at line 3162 of file memory.c.

References BMS_BufMem::firstfree, and NULL.

Referenced by exitPresolve(), initPresolve(), presolve(), presolveRound(), priceAndCutLoop(), propagationRound(), propAndSolve(), SCIPprimalHeuristics(), SCIPsolveCIP(), separationRoundLP(), and solveNode().

◆ BMSgetBufferMemoryUsed()

long long BMSgetBufferMemoryUsed ( const BMS_BUFMEM buffer)

returns the number of allocated bytes in the buffer memory

Parameters
bufferbuffer memory

Definition at line 3172 of file memory.c.

References BMS_BufMem::ndata, NULL, BMS_BufMem::size, and BMS_BufMem::totalmem.

Referenced by SCIPmemGetTotal(), and SCIPmemGetUsed().

◆ BMSprintBufferMemory()

void BMSprintBufferMemory ( BMS_BUFMEM buffer)

outputs statistics about currently allocated buffers to the screen

Parameters
buffermemory buffer storage

Definition at line 3190 of file memory.c.

References BMS_BufMem::data, BMS_BufMem::ndata, NULL, BMS_BufMem::size, and BMS_BufMem::used.

Referenced by SCIPprintMemoryDiagnostic().