coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mem_pool.h File Reference
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
Include dependency graph for mem_pool.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  mem_pool
 

Macros

#define MEM_POOL_INIT(buf_, size_, alignment_)
 

Functions

static void mem_pool_reset (struct mem_pool *mp)
 
static void mem_pool_init (struct mem_pool *mp, void *buf, size_t sz, size_t alignment)
 
voidmem_pool_alloc (struct mem_pool *mp, size_t sz)
 
void mem_pool_free (struct mem_pool *mp, void *alloc)
 

Macro Definition Documentation

◆ MEM_POOL_INIT

#define MEM_POOL_INIT (   buf_,
  size_,
  alignment_ 
)
Value:
{ \
.buf = (buf_), \
.size = (size_), \
.alignment = (alignment_), \
.last_alloc = NULL, \
.second_to_last_alloc = NULL, \
.free_offset = 0, \
}
#define NULL
Definition: stddef.h:19

Definition at line 32 of file mem_pool.h.

Function Documentation

◆ mem_pool_alloc()

void* mem_pool_alloc ( struct mem_pool mp,
size_t  sz 
)

◆ mem_pool_free()

void mem_pool_free ( struct mem_pool mp,
void alloc 
)

◆ mem_pool_init()

static void mem_pool_init ( struct mem_pool mp,
void buf,
size_t  sz,
size_t  alignment 
)
inlinestatic

Definition at line 50 of file mem_pool.h.

References mem_pool::alignment, assert, mem_pool::buf, buf, mem_pool_reset(), and mem_pool::size.

Referenced by switch_to_postram_cache().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mem_pool_reset()

static void mem_pool_reset ( struct mem_pool mp)
inlinestatic

Definition at line 42 of file mem_pool.h.

References mem_pool::free_offset, mem_pool::last_alloc, NULL, and mem_pool::second_to_last_alloc.

Referenced by mem_pool_init().

Here is the caller graph for this function: