memory allocation routines
Definition in file memory.c.
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "scip/config.h"
#include <stdint.h>
#include "blockmemshell/memory.h"
#include "scip/rbtree.h"
Go to the source code of this file.
Data Structures | |
struct | BMS_BufMem |
Macros | |
#define | debugMessage while( FALSE ) printf |
#define | errorMessage |
#define | printErrorHeader(f, l) |
#define | printError printf |
#define | printInfo printf |
#define | LONGINT_FORMAT SCIP_LONGINT_FORMAT |
#define | MAXMEMSIZE SCIP_MAXMEMSIZE |
#define | addMemlistEntry(ptr, size, filename, line) |
#define | removeMemlistEntry(ptr, filename, line) |
#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 | CHUNK_LT(ptr, chunk) |
#define | CHUNK_GT(ptr, chunk) |
#define | checkChunk(chunk) |
#define | checkChkmem(chkmem) |
#define | checkBlkmem(blkmem) |
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 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 CHUNK * | findChunk (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) |
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_CHKMEM * | createChkmem (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_CHKMEM * | BMScreateChunkMemory_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_CHKMEM * | findChkmem (const BMS_BLKMEM *blkmem, const void *ptr) |
static int | getHashNumber (int size) |
BMS_BLKMEM * | BMScreateBlockMemory_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 * | BMSallocClearBlockMemory_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_BUFMEM * | BMScreateBufferMemory_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) |
Definition at line 89 of file memory.c.
Referenced by allocChunkElement(), BMSallocBlockMemory_work(), BMSallocBufferMemory_work(), BMSallocChunkMemory_call(), BMSallocClearMemory_call(), BMSallocMemory_call(), BMSallocMemoryArray_call(), BMSclearChunkMemory_call(), BMScreateChunkMemory_call(), BMSdestroyChunkMemory_call(), BMSfreeBlockMemory_work(), BMSfreeBufferMemory_work(), BMSfreeChunkMemory_call(), BMSfreeChunkMemoryNull_call(), BMSgarbagecollectChunkMemory_call(), BMSreallocBufferMemory_work(), createChunk(), destroyChunk(), freeChunk(), freeChunkElement(), garbagecollectChkmem(), linkChunk(), and unlinkChunk().
#define errorMessage | ( | void | ) |
Definition at line 90 of file memory.c.
Referenced by BMScheckEmptyBlockMemory_call(), and garbagecollectChkmem().
#define printErrorHeader | ( | f, | |
l ) |
Definition at line 91 of file memory.c.
Referenced by BMSallocBlockMemory_call(), BMSallocBlockMemory_work(), BMSallocBlockMemoryArray_call(), BMSallocBufferMemory_call(), BMSallocBufferMemory_work(), BMSallocBufferMemoryArray_call(), BMSallocChunkMemory_call(), BMSallocClearMemory_call(), BMSallocMemory_call(), BMSallocMemoryArray_call(), BMSclearBlockMemory_call(), BMSclearChunkMemory_call(), BMScreateBlockMemory_call(), BMScreateBufferMemory_call(), BMScreateChunkMemory_call(), BMSdestroyBlockMemory_call(), BMSdestroyBufferMemory_call(), BMSdestroyChunkMemory_call(), BMSfreeBlockMemory_call(), BMSfreeBlockMemory_work(), BMSfreeBufferMemory_call(), BMSfreeBufferMemory_work(), BMSfreeChunkMemory_call(), BMSfreeMemory_call(), BMSreallocBlockMemory_call(), BMSreallocBlockMemoryArray_call(), BMSreallocBufferMemory_call(), BMSreallocBufferMemory_work(), BMSreallocBufferMemoryArray_call(), BMSreallocMemory_call(), BMSreallocMemoryArray_call(), and freeChkmemElement().
#define printError printf |
Definition at line 92 of file memory.c.
Referenced by BMSallocBlockMemory_call(), BMSallocBlockMemory_work(), BMSallocBlockMemoryArray_call(), BMSallocBufferMemory_call(), BMSallocBufferMemory_work(), BMSallocBufferMemoryArray_call(), BMSallocChunkMemory_call(), BMSallocClearMemory_call(), BMSallocMemory_call(), BMSallocMemoryArray_call(), BMSclearBlockMemory_call(), BMSclearChunkMemory_call(), BMScreateBlockMemory_call(), BMScreateBufferMemory_call(), BMScreateChunkMemory_call(), BMSdestroyBlockMemory_call(), BMSdestroyBufferMemory_call(), BMSdestroyChunkMemory_call(), BMSfreeBlockMemory_call(), BMSfreeBlockMemory_work(), BMSfreeBufferMemory_call(), BMSfreeBufferMemory_work(), BMSfreeChunkMemory_call(), BMSfreeMemory_call(), BMSreallocBlockMemory_call(), BMSreallocBlockMemoryArray_call(), BMSreallocBufferMemory_call(), BMSreallocBufferMemory_work(), BMSreallocBufferMemoryArray_call(), BMSreallocMemory_call(), BMSreallocMemoryArray_call(), and freeChkmemElement().
#define printInfo printf |
Definition at line 98 of file memory.c.
Referenced by BMSdisplayBlockMemory_call(), and BMSdisplayMemory_call().
#define LONGINT_FORMAT SCIP_LONGINT_FORMAT |
Definition at line 117 of file memory.c.
Referenced by BMScheckEmptyBlockMemory_call().
#define MAXMEMSIZE SCIP_MAXMEMSIZE |
Definition at line 124 of file memory.c.
Referenced by BMSallocBlockMemory_call(), BMSallocBlockMemoryArray_call(), BMSallocBufferMemory_call(), BMSallocBufferMemoryArray_call(), BMSallocClearMemory_call(), BMSallocMemory_call(), BMSallocMemoryArray_call(), BMSreallocBlockMemory_call(), BMSreallocBlockMemoryArray_call(), BMSreallocBufferMemory_call(), BMSreallocBufferMemoryArray_call(), BMSreallocMemory_call(), BMSreallocMemoryArray_call(), and createChunk().
#define addMemlistEntry | ( | ptr, | |
size, | |||
filename, | |||
line ) |
Definition at line 308 of file memory.c.
Referenced by BMSallocClearMemory_call(), BMSallocMemory_call(), BMSallocMemoryArray_call(), BMSreallocMemory_call(), and BMSreallocMemoryArray_call().
#define removeMemlistEntry | ( | ptr, | |
filename, | |||
line ) |
Definition at line 309 of file memory.c.
Referenced by BMSfreeMemory_call(), BMSfreeMemoryNull_call(), BMSreallocMemory_call(), and BMSreallocMemoryArray_call().
#define CHKHASH_POWER 10 |
power for size of chunk block hash table
Definition at line 665 of file memory.c.
Referenced by getHashNumber().
#define CHKHASH_SIZE (1<<CHKHASH_POWER) |
size of chunk block hash table is 2^CHKHASH_POWER
Definition at line 666 of file memory.c.
Referenced by BMScheckEmptyBlockMemory_call(), BMSclearBlockMemory_call(), BMScreateBlockMemory_call(), BMSdisplayBlockMemory_call(), BMSgarbagecollectBlockMemory_call(), and findChkmem().
#define CHUNKLENGTH_MIN 1024 |
minimal size of a chunk (in bytes)
Definition at line 693 of file memory.c.
Referenced by createChunk().
#define CHUNKLENGTH_MAX 1048576 |
maximal size of a chunk (in bytes)
Definition at line 694 of file memory.c.
Referenced by createChunk().
#define STORESIZE_MAX 8192 |
maximal number of elements in one chunk
Definition at line 695 of file memory.c.
Referenced by createChunk().
#define GARBAGE_SIZE 256 |
size of lazy free list to start garbage collection
Definition at line 696 of file memory.c.
Referenced by freeChkmemElement().
#define ALIGNMENT (sizeof(FREELIST)) |
minimal alignment of chunks
Definition at line 697 of file memory.c.
Referenced by alignSize(), BMSalignMemsize(), and BMSisAligned().
#define CHUNK_GT | ( | ptr, | |
chunk ) |
#define checkChunk | ( | chunk | ) |
Definition at line 925 of file memory.c.
Referenced by allocChunkElement(), and freeChunkElement().
#define checkChkmem | ( | chkmem | ) |
Definition at line 926 of file memory.c.
Referenced by allocChkmemElement(), BMSallocChunkMemory_call(), BMSfreeChunkMemory_call(), BMSfreeChunkMemoryNull_call(), createChunk(), freeChkmemElement(), and garbagecollectChkmem().
#define checkBlkmem | ( | blkmem | ) |
Definition at line 1691 of file memory.c.
Referenced by BMSallocBlockMemory_work(), BMSfreeBlockMemory_call(), BMSfreeBlockMemory_work(), BMSfreeBlockMemoryNull_call(), and BMSgarbagecollectBlockMemory_call().
typedef struct Freelist FREELIST |
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 ) |
allocates array and initializes it with 0; returns NULL if memory allocation failed
num | number of memory element to allocate |
typesize | size of one memory element to allocate |
filename | source file where the allocation is performed |
line | line number in source file where the allocation is performed |
Definition at line 350 of file memory.c.
References addMemlistEntry, assert(), debugMessage, MAX, MAXMEMSIZE, NULL, printError, and printErrorHeader.
void * BMSallocMemory_call | ( | size_t | size, |
const char * | filename, | ||
int | line ) |
allocates memory; returns NULL if memory allocation failed
size | size of memory element to allocate |
filename | source file where the allocation is performed |
line | line number in source file where the allocation is performed |
Definition at line 389 of file memory.c.
References addMemlistEntry, debugMessage, MAX, MAXMEMSIZE, NULL, printError, and printErrorHeader.
Referenced by BMSduplicateMemory_call().
void * BMSallocMemoryArray_call | ( | size_t | num, |
size_t | typesize, | ||
const char * | filename, | ||
int | line ) |
allocates array; returns NULL if memory allocation failed
num | number of components of array to allocate |
typesize | size of each component |
filename | source file where the allocation is performed |
line | line number in source file where the allocation is performed |
Definition at line 423 of file memory.c.
References addMemlistEntry, debugMessage, MAX, MAXMEMSIZE, NULL, printError, and printErrorHeader.
Referenced by BMSduplicateMemoryArray_call().
void * BMSreallocMemory_call | ( | void * | ptr, |
size_t | size, | ||
const char * | filename, | ||
int | line ) |
allocates memory; returns NULL if memory allocation failed
ptr | pointer to memory to reallocate |
size | new size of memory element |
filename | source file where the reallocation is performed |
line | line number in source file where the reallocation is performed |
Definition at line 461 of file memory.c.
References addMemlistEntry, MAX, MAXMEMSIZE, NULL, printError, printErrorHeader, and removeMemlistEntry.
void * BMSreallocMemoryArray_call | ( | void * | ptr, |
size_t | num, | ||
size_t | typesize, | ||
const char * | filename, | ||
int | line ) |
reallocates array; returns NULL if memory allocation failed
ptr | pointer to memory to reallocate |
num | number of components of array to allocate |
typesize | size of each component |
filename | source file where the reallocation is performed |
line | line number in source file where the reallocation is performed |
Definition at line 497 of file memory.c.
References addMemlistEntry, MAX, MAXMEMSIZE, NULL, printError, printErrorHeader, and removeMemlistEntry.
void BMSclearMemory_call | ( | void * | ptr, |
size_t | size ) |
void BMScopyMemory_call | ( | void * | ptr, |
const void * | source, | ||
size_t | size ) |
copies the contents of one memory element into another memory element
ptr | pointer to target memory element |
source | pointer to source memory element |
size | size of memory element to copy |
Definition at line 549 of file memory.c.
References assert(), and NULL.
Referenced by BMSduplicateMemory_call(), and BMSduplicateMemoryArray_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
ptr | pointer to target memory element |
source | pointer to source memory element |
size | size of memory element to copy |
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
source | pointer to source memory element |
size | size of memory element to copy |
filename | source file where the duplication is performed |
line | line number in source file where the duplication is performed |
Definition at line 581 of file memory.c.
References assert(), BMSallocMemory_call(), BMScopyMemory_call(), and NULL.
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
source | pointer to source memory element |
num | number of components of array to allocate |
typesize | size of each component |
filename | source file where the duplication is performed |
line | line number in source file where the duplication is performed |
Definition at line 600 of file memory.c.
References assert(), BMSallocMemoryArray_call(), BMScopyMemory_call(), and NULL.
void BMSfreeMemory_call | ( | void ** | ptr, |
const char * | filename, | ||
int | line ) |
frees an allocated memory element and sets pointer to NULL
ptr | pointer to pointer to memory element |
filename | source file where the deallocation is performed |
line | line number in source file where the deallocation is performed |
Definition at line 620 of file memory.c.
References assert(), NULL, printError, printErrorHeader, and removeMemlistEntry.
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
ptr | pointer to pointer to memory element |
filename | source file where the deallocation is performed |
line | line number in source file where the deallocation is performed |
Definition at line 642 of file memory.c.
References assert(), NULL, and removeMemlistEntry.
|
static |
aligns the given byte size corresponding to the minimal alignment
size | pointer to the size to align |
Definition at line 757 of file memory.c.
References ALIGNMENT.
Referenced by BMSalignMemsize(), BMSallocBlockMemory_work(), BMScreateChunkMemory_call(), BMSfreeBlockMemory_work(), and BMSreallocBlockMemory_call().
void BMSalignMemsize | ( | size_t * | size | ) |
aligns the given byte size corresponding to the minimal alignment for chunk and block memory
size | pointer to the size to align |
Definition at line 768 of file memory.c.
References ALIGNMENT, alignSize(), and assert().
int BMSisAligned | ( | size_t | size | ) |
checks whether the given size meets the alignment conditions for chunk and block memory
size | size to check for alignment |
Definition at line 777 of file memory.c.
References ALIGNMENT, and assert().
Referenced by createChkmem(), createChunk(), and getHashNumber().
|
static |
checks, if the given pointer belongs to the given chunk
chunk | memory chunk |
ptr | pointer |
Definition at line 788 of file memory.c.
References assert(), and NULL.
Referenced by freeChunkElement().
|
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
chkmem | chunk block |
ptr | pointer |
Definition at line 805 of file memory.c.
References assert(), and NULL.
Referenced by garbagecollectChkmem(), and isPtrInChkmem().
|
static |
checks, if a pointer belongs to a chunk of the given chunk block
chkmem | chunk block |
ptr | pointer |
Definition at line 824 of file memory.c.
References assert(), findChunk(), and NULL.
Referenced by findChkmem(), and freeChkmemElement().
|
static |
links chunk to the block's chunk array, sort it by store pointer; returns TRUE if successful, FALSE otherwise
chkmem | chunk block |
chunk | memory chunk |
Definition at line 934 of file memory.c.
References assert(), debugMessage, NULL, SCIPrbtreeInsert, and TRUE.
Referenced by createChunk().
|
static |
unlinks chunk from the chunk block's chunk list
chunk | memory chunk |
Definition at line 962 of file memory.c.
References assert(), debugMessage, NULL, and SCIPrbtreeDelete.
Referenced by freeChunk().
|
static |
links chunk to the chunk block's eager chunk list
chkmem | chunk block |
chunk | memory chunk |
Definition at line 989 of file memory.c.
References assert(), and NULL.
Referenced by freeChunkElement().
|
static |
unlinks chunk from the chunk block's eager chunk list
chunk | memory chunk |
Definition at line 1010 of file memory.c.
References assert(), and NULL.
Referenced by allocChunkElement(), and freeChunk().
|
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
chkmem | chunk block |
memsize | pointer to total size of allocated memory (or NULL) |
Definition at line 1035 of file memory.c.
References assert(), BMSallocMemorySize, BMSisAligned(), checkChkmem, CHUNKLENGTH_MAX, CHUNKLENGTH_MIN, debugMessage, FALSE, i, linkChunk(), MAX, MAXMEMSIZE, MIN, NULL, and STORESIZE_MAX.
Referenced by allocChkmemElement().
|
static |
destroys a chunk without updating the chunk lists
chunk | memory chunk |
memsize | pointer to total size of allocated memory (or NULL) |
Definition at line 1110 of file memory.c.
References assert(), BMSfreeMemory, debugMessage, and NULL.
Referenced by freeChunk().
|
static |
removes a completely unused chunk, i.e. a chunk with all elements in the eager free list
chunk | memory chunk |
memsize | pointer to total size of allocated memory (or NULL) |
Definition at line 1129 of file memory.c.
References assert(), debugMessage, destroyChunk(), NULL, unlinkChunk(), and unlinkEagerChunk().
Referenced by garbagecollectChkmem().
|
static |
returns an element of the eager free list and removes it from the list
chunk | memory chunk |
Definition at line 1161 of file memory.c.
References assert(), checkChunk, debugMessage, NULL, and unlinkEagerChunk().
Referenced by allocChkmemElement().
|
static |
puts given pointer into the eager free list and adds the chunk to the eager list of its chunk block, if necessary
chunk | memory chunk |
ptr | pointer |
Definition at line 1198 of file memory.c.
References assert(), checkChunk, debugMessage, isPtrInChunk(), linkEagerChunk(), and NULL.
Referenced by garbagecollectChkmem().
|
static |
creates a new chunk block data structure
size | element size of the chunk block |
initchunksize | number of elements in the first chunk of the chunk block |
garbagefactor | garbage collector is called, if at least garbagefactor * avg. chunksize elements are free (-1: disable garbage collection) |
memsize | pointer to total size of allocated memory (or NULL) |
Definition at line 1227 of file memory.c.
References assert(), BMSallocMemory, BMSisAligned(), and NULL.
Referenced by BMSallocBlockMemory_work(), and BMScreateChunkMemory_call().
|
static |
destroys all chunks of the chunk block, but keeps the chunk block header structure
chkmem | chunk block |
memsize | pointer to total size of allocated memory (or NULL) |
Definition at line 1271 of file memory.c.
References assert(), FOR_EACH_NODE, and NULL.
Referenced by BMSclearChunkMemory_call(), destroyChkmem(), and garbagecollectChkmem().
|
static |
deletes chunk block and frees all associated memory chunks
chkmem | pointer to chunk block |
memsize | pointer to total size of allocated memory (or NULL) |
Definition at line 1296 of file memory.c.
References assert(), BMSfreeMemory, BMSfreeMemoryArrayNull, clearChkmem(), and NULL.
Referenced by BMSclearBlockMemory_call(), BMSdestroyChunkMemory_call(), and BMSgarbagecollectBlockMemory_call().
|
static |
allocates a new memory element from the chunk block
chkmem | chunk block |
memsize | pointer to total size of allocated memory (or NULL) |
Definition at line 1318 of file memory.c.
References allocChunkElement(), assert(), checkChkmem, createChunk(), and NULL.
Referenced by BMSallocBlockMemory_work(), and BMSallocChunkMemory_call().
|
static |
sorts the lazy free list of the chunk block into the eager free lists of the chunks, and removes completely unused chunks
chkmem | chunk block |
memsize | pointer to total size of allocated memory (or NULL) |
Definition at line 1358 of file memory.c.
References assert(), checkChkmem, clearChkmem(), debugMessage, errorMessage, findChunk(), freeChunk(), freeChunkElement(), and NULL.
Referenced by BMSgarbagecollectBlockMemory_call(), BMSgarbagecollectChunkMemory_call(), and freeChkmemElement().
|
static |
frees a memory element and returns it to the lazy freelist of the chunk block
chkmem | chunk block |
ptr | memory element |
memsize | pointer to total size of allocated memory (or NULL) |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 1426 of file memory.c.
References assert(), checkChkmem, GARBAGE_SIZE, garbagecollectChkmem(), isPtrInChkmem(), NULL, printError, and printErrorHeader.
Referenced by BMSfreeBlockMemory_work(), BMSfreeChunkMemory_call(), and BMSfreeChunkMemoryNull_call().
BMS_CHKMEM * BMScreateChunkMemory_call | ( | size_t | size, |
int | initchunksize, | ||
int | garbagefactor, | ||
const char * | filename, | ||
int | line ) |
creates a new chunk block data structure
size | element size of the chunk block |
initchunksize | number of elements in the first chunk of the chunk block |
garbagefactor | garbage collector is called, if at least garbagefactor * avg. chunksize elements are free (-1: disable garbage collection) |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 1463 of file memory.c.
References alignSize(), createChkmem(), debugMessage, NULL, printError, and printErrorHeader.
void BMSclearChunkMemory_call | ( | BMS_CHKMEM * | chkmem, |
const char * | filename, | ||
int | line ) |
clears a chunk block data structure
chkmem | chunk block |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 1487 of file memory.c.
References clearChkmem(), debugMessage, NULL, printError, and printErrorHeader.
void BMSdestroyChunkMemory_call | ( | BMS_CHKMEM ** | chkmem, |
const char * | filename, | ||
int | line ) |
destroys and frees a chunk block data structure
chkmem | pointer to chunk block |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 1505 of file memory.c.
References assert(), debugMessage, destroyChkmem(), NULL, printError, and printErrorHeader.
void * BMSallocChunkMemory_call | ( | BMS_CHKMEM * | chkmem, |
size_t | size, | ||
const char * | filename, | ||
int | line ) |
allocates a memory element of the given chunk block
chkmem | chunk block |
size | size of memory element to allocate (only needed for sanity check) |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 1525 of file memory.c.
References allocChkmemElement(), assert(), checkChkmem, debugMessage, NULL, printError, and printErrorHeader.
Referenced by 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
chkmem | chunk block |
source | source memory element |
size | size of memory element to allocate (only needed for sanity check) |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 1552 of file memory.c.
References assert(), BMSallocChunkMemory_call(), BMScopyMemorySize, and NULL.
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
chkmem | chunk block |
ptr | pointer to pointer to memory element to free |
size | size of memory element to allocate (only needed for sanity check) |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 1574 of file memory.c.
References assert(), checkChkmem, debugMessage, freeChkmemElement(), NULL, printError, and printErrorHeader.
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
chkmem | chunk block |
ptr | pointer to pointer to memory element to free |
size | size of memory element to allocate (only needed for sanity check) |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 1603 of file memory.c.
References assert(), checkChkmem, debugMessage, freeChkmemElement(), and NULL.
void BMSgarbagecollectChunkMemory_call | ( | BMS_CHKMEM * | chkmem | ) |
calls garbage collection of chunk block and frees chunks without allocated memory elements
chkmem | chunk block |
Definition at line 1627 of file memory.c.
References debugMessage, garbagecollectChkmem(), and NULL.
long long BMSgetChunkMemoryUsed_call | ( | const BMS_CHKMEM * | chkmem | ) |
|
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.
blkmem | block memory |
ptr | memory element to search |
Definition at line 1701 of file memory.c.
References assert(), CHKHASH_SIZE, i, isPtrInChkmem(), and NULL.
Referenced by BMSgetBlockPointerSize_call().
|
static |
calculates hash number of memory size
size | element size |
Definition at line 1724 of file memory.c.
References assert(), BMSisAligned(), and CHKHASH_POWER.
Referenced by BMSallocBlockMemory_work(), and BMSfreeBlockMemory_work().
BMS_BLKMEM * BMScreateBlockMemory_call | ( | int | initchunksize, |
int | garbagefactor, | ||
const char * | filename, | ||
int | line ) |
creates a block memory allocation data structure
initchunksize | number of elements in the first chunk of each chunk block |
garbagefactor | garbage collector is called, if at least garbagefactor * avg. chunksize elements are free (-1: disable garbage collection) |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 1735 of file memory.c.
References BMSallocMemory, CHKHASH_SIZE, i, NULL, printError, and printErrorHeader.
void BMSclearBlockMemory_call | ( | BMS_BLKMEM * | blkmem, |
const char * | filename, | ||
int | line ) |
frees all chunk blocks in the block memory
blkmem | block memory |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 1769 of file memory.c.
References assert(), CHKHASH_SIZE, destroyChkmem(), i, NULL, printError, and printErrorHeader.
Referenced by BMSdestroyBlockMemory_call().
void BMSdestroyBlockMemory_call | ( | BMS_BLKMEM ** | blkmem, |
const char * | filename, | ||
int | line ) |
clears and deletes block memory
blkmem | pointer to block memory |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 1803 of file memory.c.
References assert(), BMSclearBlockMemory_call(), BMSfreeMemory, NULL, printError, and printErrorHeader.
|
static |
work for allocating memory in the block memory pool
blkmem | block memory |
size | size of memory element to allocate |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 1826 of file memory.c.
References alignSize(), allocChkmemElement(), assert(), BMSduplicateMemoryArray, BMSfreeMemoryArrayNull, checkBlkmem, createChkmem(), debugMessage, getHashNumber(), MAX, NULL, printError, and printErrorHeader.
Referenced by BMSallocBlockMemory_call(), and BMSallocBlockMemoryArray_call().
void * BMSallocBlockMemory_call | ( | BMS_BLKMEM * | blkmem, |
size_t | size, | ||
const char * | filename, | ||
int | line ) |
allocates memory in the block memory pool
blkmem | block memory |
size | size of memory element to allocate |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 1897 of file memory.c.
References BMSallocBlockMemory_work(), MAXMEMSIZE, NULL, printError, and printErrorHeader.
Referenced by BMSallocClearBlockMemory_call(), BMSduplicateBlockMemory_call(), and BMSreallocBlockMemory_call().
void * BMSallocClearBlockMemory_call | ( | BMS_BLKMEM * | blkmem, |
size_t | size, | ||
const char * | filename, | ||
int | line ) |
allocates memory in the block memory pool and clears it
blkmem | block memory |
size | size of memory element to allocate |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 1917 of file memory.c.
References BMSallocBlockMemory_call(), BMSclearMemorySize, and NULL.
void * BMSallocBlockMemoryArray_call | ( | BMS_BLKMEM * | blkmem, |
size_t | num, | ||
size_t | typesize, | ||
const char * | filename, | ||
int | line ) |
allocates array in the block memory pool
blkmem | block memory |
num | size of array to be allocated |
typesize | size of each component |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 1934 of file memory.c.
References BMSallocBlockMemory_work(), MAXMEMSIZE, NULL, printError, and printErrorHeader.
Referenced by BMSallocClearBlockMemoryArray_call(), BMSduplicateBlockMemoryArray_call(), and BMSreallocBlockMemoryArray_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
blkmem | block memory |
num | size of array to be allocated |
typesize | size of each component |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 1955 of file memory.c.
References BMSallocBlockMemoryArray_call(), BMSclearMemorySize, and NULL.
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
blkmem | block memory |
ptr | memory element to reallocated |
oldsize | old size of memory element |
newsize | new size of memory element |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 1973 of file memory.c.
References alignSize(), assert(), BMSallocBlockMemory_call(), BMScopyMemorySize, BMSfreeBlockMemory_call(), MAXMEMSIZE, MIN, NULL, printError, and printErrorHeader.
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
blkmem | block memory |
ptr | memory element to reallocated |
oldnum | old size of array |
newnum | new size of array |
typesize | size of each component |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 2013 of file memory.c.
References assert(), BMSallocBlockMemoryArray_call(), BMScopyMemorySize, BMSfreeBlockMemory_call(), MAXMEMSIZE, MIN, NULL, printError, and printErrorHeader.
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
blkmem | block memory |
source | memory element to duplicate |
size | size of memory elements |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 2052 of file memory.c.
References assert(), BMSallocBlockMemory_call(), BMScopyMemorySize, and NULL.
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
blkmem | block memory |
source | memory element to duplicate |
num | size of array to be duplicated |
typesize | size of each component |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 2072 of file memory.c.
References assert(), BMSallocBlockMemoryArray_call(), BMScopyMemorySize, and NULL.
|
static |
common work for freeing block memory
blkmem | block memory |
ptr | pointer to pointer to memory element to free |
size | size of memory element |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 2094 of file memory.c.
References alignSize(), assert(), checkBlkmem, debugMessage, freeChkmemElement(), getHashNumber(), MAX, NULL, printError, and printErrorHeader.
Referenced by BMSfreeBlockMemory_call(), and BMSfreeBlockMemoryNull_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
blkmem | block memory |
ptr | pointer to pointer to memory element to free |
size | size of memory element |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 2142 of file memory.c.
References assert(), BMSfreeBlockMemory_work(), checkBlkmem, NULL, printError, and printErrorHeader.
Referenced by BMSreallocBlockMemory_call(), and BMSreallocBlockMemoryArray_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
blkmem | block memory |
ptr | pointer to pointer to memory element to free |
size | size of memory element |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 2164 of file memory.c.
References assert(), BMSfreeBlockMemory_work(), checkBlkmem, and NULL.
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
blkmem | block memory |
Definition at line 2185 of file memory.c.
References assert(), checkBlkmem, CHKHASH_SIZE, destroyChkmem(), garbagecollectChkmem(), i, and NULL.
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 ) |
returns the size of the given memory element; returns 0, if the element is not member of the block memory
blkmem | block memory |
ptr | memory element |
Definition at line 2279 of file memory.c.
References assert(), findChkmem(), and NULL.
void BMSdisplayBlockMemory_call | ( | const BMS_BLKMEM * | blkmem | ) |
outputs allocation diagnostics of block memory
blkmem | block memory |
Definition at line 2299 of file memory.c.
References assert(), CHKHASH_SIZE, FOR_EACH_NODE, i, NULL, and printInfo.
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
blkmem | block memory |
Definition at line 2423 of file memory.c.
References assert(), CHKHASH_SIZE, errorMessage, FOR_EACH_NODE, i, LONGINT_FORMAT, NULL, and SCIP_UNUSED.
BMS_BUFMEM * BMScreateBufferMemory_call | ( | double | arraygrowfac, |
int | arraygrowinit, | ||
unsigned int | clean, | ||
const char * | filename, | ||
int | line ) |
creates memory buffer storage
arraygrowfac | memory growing factor for dynamically allocated arrays |
arraygrowinit | initial size of dynamically allocated arrays |
clean | should the memory blocks in the buffer be initialized to zero? |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 2518 of file memory.c.
References BMS_BufMem::arraygrowfac, BMS_BufMem::arraygrowinit, assert(), 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.
void BMSdestroyBufferMemory_call | ( | BMS_BUFMEM ** | buffer, |
const char * | filename, | ||
int | line ) |
destroys buffer memory
buffer | pointer to memory buffer storage |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 2554 of file memory.c.
References assert(), BMSfreeMemory, BMSfreeMemoryArrayNull, i, NULL, printError, and printErrorHeader.
void BMSsetBufferMemoryArraygrowfac | ( | BMS_BUFMEM * | buffer, |
double | arraygrowfac ) |
set arraygrowfac
buffer | pointer to memory buffer storage |
arraygrowfac | memory growing factor for dynamically allocated arrays |
Definition at line 2587 of file memory.c.
References BMS_BufMem::arraygrowfac, assert(), and NULL.
Referenced by SCIP_DECL_PARAMCHGD().
void BMSsetBufferMemoryArraygrowinit | ( | BMS_BUFMEM * | buffer, |
int | arraygrowinit ) |
set arraygrowinit
buffer | pointer to memory buffer storage |
arraygrowinit | initial size of dynamically allocated arrays |
Definition at line 2599 of file memory.c.
References BMS_BufMem::arraygrowinit, assert(), and NULL.
Referenced by SCIP_DECL_PARAMCHGD().
|
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.
initsize | initial size of array |
growfac | growing factor of array |
num | minimum number of entries to store |
Definition at line 2616 of file memory.c.
References assert(), MAX, and SCIP_Real.
Referenced by BMSallocBufferMemory_work(), and BMSreallocBufferMemory_work().
|
static |
work for allocating the next unused buffer
buffer | memory buffer storage |
size | minimal required size of the buffer |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 2658 of file memory.c.
References BMS_BufMem::arraygrowfac, BMS_BufMem::arraygrowinit, assert(), BMSallocClearMemorySize, BMSallocMemorySize, BMSclearMemorySize, BMSreallocMemoryArray, BMSreallocMemorySize, calcMemoryGrowSize(), BMS_BufMem::clean, BMS_BufMem::data, debugMessage, FALSE, BMS_BufMem::firstfree, i, MAX, BMS_BufMem::ndata, NULL, printError, printErrorHeader, BMS_BufMem::size, BMS_BufMem::totalmem, TRUE, and BMS_BufMem::used.
Referenced by BMSallocBufferMemory_call(), and BMSallocBufferMemoryArray_call().
void * BMSallocBufferMemory_call | ( | BMS_BUFMEM * | buffer, |
size_t | size, | ||
const char * | filename, | ||
int | line ) |
allocates the next unused buffer
buffer | memory buffer storage |
size | minimal required size of the buffer |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 2792 of file memory.c.
References BMSallocBufferMemory_work(), MAXMEMSIZE, NULL, printError, and printErrorHeader.
Referenced by BMSduplicateBufferMemory_call(), and BMSreallocBufferMemory_work().
void * BMSallocBufferMemoryArray_call | ( | BMS_BUFMEM * | buffer, |
size_t | num, | ||
size_t | typesize, | ||
const char * | filename, | ||
int | line ) |
allocates the next unused buffer array
buffer | memory buffer storage |
num | size of array to be allocated |
typesize | size of components |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 2812 of file memory.c.
References BMSallocBufferMemory_work(), MAXMEMSIZE, NULL, printError, and printErrorHeader.
Referenced by BMSallocClearBufferMemoryArray_call(), and BMSduplicateBufferMemoryArray_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
buffer | memory buffer storage |
num | size of array to be allocated |
typesize | size of components |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 2833 of file memory.c.
References BMSallocBufferMemoryArray_call(), BMSclearMemorySize, and NULL.
|
static |
work for reallocating the buffer to at least the given size
buffer | memory buffer storage |
ptr | pointer to the allocated memory buffer |
size | minimal required size of the buffer |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 2852 of file memory.c.
References BMS_BufMem::arraygrowfac, BMS_BufMem::arraygrowinit, assert(), 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().
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
buffer | memory buffer storage |
ptr | pointer to the allocated memory buffer |
size | minimal required size of the buffer |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 2924 of file memory.c.
References BMSreallocBufferMemory_work(), MAXMEMSIZE, NULL, printError, and printErrorHeader.
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
buffer | memory buffer storage |
ptr | pointer to the allocated memory buffer |
num | size of array to be allocated |
typesize | size of components |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 2945 of file memory.c.
References BMSreallocBufferMemory_work(), MAXMEMSIZE, NULL, printError, and printErrorHeader.
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
buffer | memory buffer storage |
source | memory block to copy into the buffer |
size | minimal required size of the buffer |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 2967 of file memory.c.
References assert(), BMSallocBufferMemory_call(), BMScopyMemorySize, and NULL.
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
buffer | memory buffer storage |
source | memory block to copy into the buffer |
num | size of array to be allocated |
typesize | size of components |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 2990 of file memory.c.
References assert(), BMSallocBufferMemoryArray_call(), BMScopyMemorySize, and NULL.
|
static |
work for freeing a buffer
buffer | memory buffer storage |
ptr | pointer to pointer to the allocated memory buffer |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 3015 of file memory.c.
References assert(), BMS_BufMem::clean, BMS_BufMem::data, debugMessage, FALSE, BMS_BufMem::firstfree, i, BMS_BufMem::ndata, NULL, printError, printErrorHeader, BMS_BufMem::size, and BMS_BufMem::used.
Referenced by BMSfreeBufferMemory_call(), and BMSfreeBufferMemoryNull_call().
void BMSfreeBufferMemory_call | ( | BMS_BUFMEM * | buffer, |
void ** | ptr, | ||
const char * | filename, | ||
int | line ) |
frees a buffer and sets pointer to NULL
buffer | memory buffer storage |
ptr | pointer to pointer to the allocated memory buffer |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 3086 of file memory.c.
References assert(), BMSfreeBufferMemory_work(), BMSfreeMemory, NULL, printError, and printErrorHeader.
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
buffer | memory buffer storage |
ptr | pointer to pointer to the allocated memory buffer |
filename | source file of the function call |
line | line number in source file of the function call |
Definition at line 3109 of file memory.c.
References assert(), BMSfreeBufferMemory_work(), BMSfreeMemory, and NULL.
size_t BMSgetNUsedBufferMemory | ( | BMS_BUFMEM * | buffer | ) |
gets number of used buffers
buffer | memory buffer storage |
Definition at line 3129 of file memory.c.
References assert(), BMS_BufMem::firstfree, and NULL.
Referenced by exitPresolve(), initPresolve(), presolve(), presolveRound(), priceAndCutLoop(), propagationRound(), propAndSolve(), SCIPprimalHeuristics(), SCIPsolveCIP(), separationRoundLP(), and solveNode().
long long BMSgetBufferMemoryUsed | ( | const BMS_BUFMEM * | buffer | ) |
returns the number of allocated bytes in the buffer memory
buffer | buffer memory |
Definition at line 3139 of file memory.c.
References assert(), i, BMS_BufMem::ndata, NULL, BMS_BufMem::size, and BMS_BufMem::totalmem.
Referenced by SCIPmemGetTotal(), and SCIPmemGetUsed().
void BMSprintBufferMemory | ( | BMS_BUFMEM * | buffer | ) |
outputs statistics about currently allocated buffers to the screen
buffer | memory buffer storage |
Definition at line 3157 of file memory.c.
References assert(), BMS_BufMem::data, i, BMS_BufMem::ndata, NULL, BMS_BufMem::size, and BMS_BufMem::used.
Referenced by SCIPprintMemoryDiagnostic().