|
version 1.3, 2014/01/29 14:16:53
|
version 1.7.12.1, 2024/12/05 12:33:49
|
|
Line 12 terms:
|
Line 12 terms:
|
| All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
| Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
| |
|
| Copyright 2004 - 2014 | Copyright 2004 - 2024 |
| by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
| |
|
| Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
|
Line 79 typedef struct _tagMPool {
|
Line 79 typedef struct _tagMPool {
|
| } pool_bytes; |
} pool_bytes; |
| struct { |
struct { |
| unsigned long max; |
unsigned long max; |
| |
unsigned long real; |
| unsigned long curr; |
unsigned long curr; |
| } pool_quota; |
} pool_quota; |
| |
|
|
Line 89 typedef struct _tagMPool {
|
Line 90 typedef struct _tagMPool {
|
| #define mpool_lock(x) (assert((x)), pthread_mutex_lock(&(x)->pool_mtx)) |
#define mpool_lock(x) (assert((x)), pthread_mutex_lock(&(x)->pool_mtx)) |
| #define mpool_unlock(x) (assert((x)), pthread_mutex_unlock(&(x)->pool_mtx)) |
#define mpool_unlock(x) (assert((x)), pthread_mutex_unlock(&(x)->pool_mtx)) |
| |
|
| typedef void (*mpool_stat_cb)(unsigned int, unsigned int, unsigned int); | #ifdef __cplusplus |
| | extern "C" { |
| | #endif |
| |
|
| |
typedef int (*mpool_stat_cb)(unsigned int, unsigned int, unsigned int, |
| |
void *, unsigned int); |
| |
|
| /* mpool functions */ |
/* mpool functions */ |
| |
|
| /* |
/* |
|
Line 125 int mpool_purge(mpool_t * __restrict mp, unsigned int
|
Line 131 int mpool_purge(mpool_t * __restrict mp, unsigned int
|
| */ |
*/ |
| void *mpool_malloc(mpool_t * __restrict mp, unsigned int size, const char *memname); |
void *mpool_malloc(mpool_t * __restrict mp, unsigned int size, const char *memname); |
| /* |
/* |
| |
* mpool_calloc() - Multiple memory block allocation |
| |
* |
| |
* @mp = Memory pool |
| |
* @nmemb = Number of memory blocks |
| |
* @size = Size |
| |
* @memname = Optional memory block name |
| |
* return: NULL error or !=NULL ok allocated memory |
| |
*/ |
| |
void *mpool_calloc(mpool_t * __restrict mp, u_int nmemb, u_int size, const char *memname); |
| |
/* |
| * mpool_free() Free allocated memory with mpool_alloc() |
* mpool_free() Free allocated memory with mpool_alloc() |
| * |
* |
| * @mp = Memory pool |
* @mp = Memory pool |
|
Line 198 unsigned long mpool_setquota(mpool_t * __restrict mp,
|
Line 214 unsigned long mpool_setquota(mpool_t * __restrict mp,
|
| * mpool_getquota() - Get memory quota |
* mpool_getquota() - Get memory quota |
| * |
* |
| * @mp = Memory pool |
* @mp = Memory pool |
| * @currmem = Return current memory | * @currmem = Return current memory usage |
| | * @realmem = Return current real memory usage |
| * @maxmem = Return max quota size |
* @maxmem = Return max quota size |
| * return: none |
* return: none |
| */ |
*/ |
| void mpool_getquota(mpool_t * __restrict mp, unsigned long *currmem, |
void mpool_getquota(mpool_t * __restrict mp, unsigned long *currmem, |
| unsigned long *maxmem); | unsigned long *realmem, unsigned long *maxmem); |
| /* |
/* |
| * mpool_statistics() - Dump statistics from memory pool buckets |
* mpool_statistics() - Dump statistics from memory pool buckets |
| * |
* |
| * @mp = Memory pool |
* @mp = Memory pool |
| * @cb = Export statistics to callback |
* @cb = Export statistics to callback |
| * return: none | * return: -1 error or >0 bytes in data buffer |
| */ |
*/ |
| void mpool_statistics(mpool_t * __restrict mp, mpool_stat_cb cb); | int mpool_statistics(mpool_t * __restrict mp, mpool_stat_cb cb, |
| | void *data, unsigned int datlen); |
| |
|
| |
|
| /* Wrappers */ |
/* Wrappers */ |
|
Line 253 void mpool_xfree(void * __restrict data);
|
Line 271 void mpool_xfree(void * __restrict data);
|
| * return: =NULL error or !=NULL new allocated string |
* return: =NULL error or !=NULL new allocated string |
| */ |
*/ |
| char *mpool_xstrdup(const char *str); |
char *mpool_xstrdup(const char *str); |
| |
/* |
| |
* mpool_xstatistics() - elwix default memory pool statistics wrapper |
| |
* |
| |
* @cb = Export statistics to callback |
| |
* @data = data buffer |
| |
* @datlen = data buffer length |
| |
* return: -1 error or >0 bytes in data buffer |
| |
*/ |
| |
int mpool_xstatistics(mpool_stat_cb cb, void *data, unsigned int datlen); |
| |
/* |
| |
* mpool_dump() - Dump elwix memory pool statistics |
| |
* |
| |
* @mp = memory pool, if =NULL dump elwix default memory pool |
| |
* @fmt = prefix info format string |
| |
* @... = argument(s) |
| |
* return: none |
| |
*/ |
| |
void mpool_dump(mpool_t * __restrict mp, const char *fmt, ...); |
| |
/* |
| |
* mpool_dump2() - Dump elwix memory pool statistics to string |
| |
* |
| |
* @mp = memory pool, if =NULL dump elwix default memory pool |
| |
* @str = string buffer |
| |
* @strlen = string buffer length |
| |
* return: >0 data in string buffer |
| |
*/ |
| |
int mpool_dump2(mpool_t * __restrict mp, char *str, int strlen); |
| |
|
| |
#ifdef __cplusplus |
| |
} |
| |
#endif |
| |
|
| #endif |
#endif |