![]() |
This is Unofficial EPICS BASE Doxygen Site
|
A library to manage storage that is allocated and quickly freed. More...
#include <stdlib.h>
#include "libComAPI.h"
Go to the source code of this file.
Functions | |
LIBCOM_API int | dbmfInit (size_t size, int chunkItems) |
Initialize the facility. More... | |
LIBCOM_API void * | dbmfMalloc (size_t bytes) |
Allocate memory. More... | |
LIBCOM_API char * | dbmfStrdup (const char *str) |
Duplicate a string. More... | |
LIBCOM_API char * | dbmfStrndup (const char *str, size_t len) |
Duplicate a string (up to len bytes). More... | |
LIBCOM_API char * | dbmfStrcat3 (const char *lhs, const char *mid, const char *rhs) |
Concatenate three strings. More... | |
LIBCOM_API void | dbmfFree (void *bytes) |
Free the memory allocated by dbmfMalloc. More... | |
LIBCOM_API void | dbmfFreeChunks (void) |
Free all chunks that contain only free items. More... | |
LIBCOM_API int | dbmfShow (int level) |
Show the status of the dbmf memory pool. More... | |
A library to manage storage that is allocated and quickly freed.
Database Macro/Free describes a facility that prevents memory fragmentation when temporary storage is being allocated and freed a short time later, at the same time that much longer-lived storage is also being allocated, such as when parsing items for the IOC database while also creating records.
Routines whin iocCore like dbLoadDatabase() have the following attributes:
Definition in file dbmf.h.
LIBCOM_API void dbmfFree | ( | void * | bytes | ) |
Free the memory allocated by dbmfMalloc.
bytes | Pointer to memory obtained from dbmfMalloc(), dbmfStrdup(), dbmfStrndup() or dbmfStrcat3(). |
Definition at line 175 of file dbmf.c.
LIBCOM_API void dbmfFreeChunks | ( | void | ) |
Free all chunks that contain only free items.
Definition at line 241 of file dbmf.c.
LIBCOM_API int dbmfInit | ( | size_t | size, |
int | chunkItems | ||
) |
Initialize the facility.
size | The maximum size request from dbmfMalloc() that will be allocated from the dbmf pool (Size is always made a multiple of 8). |
chunkItems | Each time malloc() must be called size*chunkItems bytes are allocated. |
Definition at line 71 of file dbmf.c.
LIBCOM_API void* dbmfMalloc | ( | size_t | bytes | ) |
Allocate memory.
bytes | If bytes > size then malloc() is used to allocate the memory. |
Definition at line 97 of file dbmf.c.
LIBCOM_API int dbmfShow | ( | int | level | ) |
Show the status of the dbmf memory pool.
level | Detail level. |
Definition at line 205 of file dbmf.c.
LIBCOM_API char* dbmfStrcat3 | ( | const char * | lhs, |
const char * | mid, | ||
const char * | rhs | ||
) |
Concatenate three strings.
Returns a pointer to a null-terminated string made by concatenating the three input strings.
lhs | Start string to which the others get concatenated to (left part). |
mid | Next string to be concatenated to the lhs (mid part). |
rhs | Last string to be concatenated to the lhs+mid (right part). |
Definition at line 289 of file dbmf.c.
LIBCOM_API char* dbmfStrdup | ( | const char * | str | ) |
LIBCOM_API char* dbmfStrndup | ( | const char * | str, |
size_t | len | ||
) |
Duplicate a string (up to len bytes).
Copy at most len bytes of the input string into a new buffer. If no nil terminator is seen in the first len
bytes a nil terminator is added.
str | Pointer to the null-terminated string to be copied. |
len | Max number of bytes to copy. |
Definition at line 167 of file dbmf.c.