MCPcopy Create free account
hub / github.com/coreboot/coreboot / mem_pool_alloc

Function mem_pool_alloc

src/commonlib/mem_pool.c:6–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include <commonlib/mem_pool.h>
5
6void *mem_pool_alloc(struct mem_pool *mp, size_t sz)
7{
8 void *p;
9
10 if (mp->alignment == 0)
11 return NULL;
12
13 /* We assume that mp->buf started mp->alignment aligned */
14 sz = ALIGN_UP(sz, mp->alignment);
15
16 /* Determine if any space available. */
17 if ((mp->size - mp->free_offset) < sz)
18 return NULL;
19
20 p = &mp->buf[mp->free_offset];
21
22 mp->free_offset += sz;
23 mp->second_to_last_alloc = mp->last_alloc;
24 mp->last_alloc = p;
25
26 return p;
27}
28
29void mem_pool_free(struct mem_pool *mp, void *p)
30{

Callers 5

mmap_helper_rdev_mmapFunction · 0.70
cbfs_preloadFunction · 0.50
do_allocFunction · 0.50
spi_dma_mmapFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected