--- libelwix/inc/elwix/ampool.h 2015/07/01 21:48:39 1.5 +++ libelwix/inc/elwix/ampool.h 2022/10/24 00:10:22 1.6 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: ampool.h,v 1.5 2015/07/01 21:48:39 misho Exp $ +* $Id: ampool.h,v 1.6 2022/10/24 00:10:22 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -12,7 +12,7 @@ terms: All of the documentation and software included in the ELWIX and AITNET Releases is copyrighted by ELWIX - Sofia/Bulgaria -Copyright 2004 - 2015 +Copyright 2004 - 2022 by Michael Pounov . All rights reserved. Redistribution and use in source and binary forms, with or without @@ -90,7 +90,8 @@ typedef struct _tagMPool { #define mpool_lock(x) (assert((x)), pthread_mutex_lock(&(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); +typedef int (*mpool_stat_cb)(unsigned int, unsigned int, unsigned int, + void *, unsigned int); /* mpool functions */ @@ -211,9 +212,10 @@ void mpool_getquota(mpool_t * __restrict mp, unsigned * * @mp = Memory pool * @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 */ @@ -256,12 +258,14 @@ void mpool_xfree(void * __restrict data); */ char *mpool_xstrdup(const char *str); /* - * mpool_xstatistics() - elwix memory pool statistics wrapper + * mpool_xstatistics() - elwix default memory pool statistics wrapper * * @cb = Export statistics to callback - * return: none + * @data = data buffer + * @datlen = data buffer length + * return: -1 error or >0 bytes in data buffer */ -void mpool_xstatistics(mpool_stat_cb cb); +int mpool_xstatistics(mpool_stat_cb cb, void *data, unsigned int datlen); /* * mpool_dump() - Dump elwix memory pool statistics * @@ -271,6 +275,15 @@ void mpool_xstatistics(mpool_stat_cb cb); * 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); #endif