NeoMutt  2022-04-29-247-gc6aae8
Teaching an old dog new tricks
pool.h File Reference

A global pool of Buffers. More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


void mutt_buffer_pool_free (void)
 Release the Buffer pool. More...
struct Buffermutt_buffer_pool_get (void)
 Get a Buffer from the pool. More...
void mutt_buffer_pool_release (struct Buffer **pbuf)
 Free a Buffer from the pool. More...

Detailed Description

A global pool of Buffers.

  • Richard Russon

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see

Definition in file pool.h.

Function Documentation

◆ mutt_buffer_pool_free()

void mutt_buffer_pool_free ( void  )

Release the Buffer pool.

Definition at line 87 of file pool.c.

89 mutt_debug(LL_DEBUG1, "%zu of %zu returned to pool\n", BufferPoolCount, BufferPoolLen);
91 while (BufferPoolCount)
94 BufferPoolLen = 0;
#define mutt_debug(LEVEL,...)
Definition: logging.h:84
Log at debug level 1.
Definition: logging.h:40
#define FREE(x)
Definition: memory.h:43
static void buffer_free(struct Buffer **p)
Release a Buffer and its contents.
Definition: pool.c:58
static size_t BufferPoolLen
Definition: pool.c:37
static size_t BufferPoolCount
Definition: pool.c:36
static struct Buffer ** BufferPool
Definition: pool.c:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_buffer_pool_get()

struct Buffer * mutt_buffer_pool_get ( void  )

Get a Buffer from the pool.

Return values

Definition at line 101 of file pool.c.

103 if (BufferPoolCount == 0)
105 return BufferPool[--BufferPoolCount];
static void increase_buffer_pool(void)
Increase the size of the Buffer pool.
Definition: pool.c:70
+ Here is the call graph for this function:

◆ mutt_buffer_pool_release()

void mutt_buffer_pool_release ( struct Buffer **  pbuf)

Free a Buffer from the pool.

[out]pbufBuffer to free

Definition at line 112 of file pool.c.

114 if (!pbuf || !*pbuf)
115 return;
118 {
119 mutt_debug(LL_DEBUG1, "Internal buffer pool error\n");
121 return;
122 }
124 struct Buffer *buf = *pbuf;
125 if ((buf->dsize > (2 * BufferPoolInitialBufferSize)) ||
127 {
129 mutt_mem_realloc(&buf->data, buf->dsize);
130 }
134 *pbuf = NULL;
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:85
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
static unsigned char * pbuf
Cached PGP data packet.
Definition: pgppacket.c:38
static size_t BufferPoolInitialBufferSize
Definition: pool.c:39
String manipulation buffer.
Definition: buffer.h:34
size_t dsize
Length of data.
Definition: buffer.h:37
char * data
Pointer to data.
Definition: buffer.h:35
+ Here is the call graph for this function: