git/mem-pool.c

/*
 * Memory Pool implementation logic.
 */

#include "git-compat-util.h"
#include "mem-pool.h"
#include "gettext.h"

#define BLOCK_GROWTH_SIZE

/*
 * The inner union is an approximation for C11's max_align_t, and the
 * struct + offsetof computes _Alignof. This can all just be replaced
 * with _Alignof(max_align_t) if/when C11 is part of the baseline.
 * Note that _Alignof(X) need not be the same as sizeof(X); it's only
 * required to be a (possibly trivial) factor. They are the same for
 * most architectures, but m68k for example has only 2-byte alignment
 * for its 4-byte and 8-byte types, so using sizeof would waste space.
 *
 * Add more types to the union if the current set is insufficient.
 */
struct git_max_alignment {};
#define GIT_MAX_ALIGNMENT

/*
 * Allocate a new mp_block and insert it after the block specified in
 * `insert_after`. If `insert_after` is NULL, then insert block at the
 * head of the linked list.
 */
static struct mp_block *mem_pool_alloc_block(struct mem_pool *pool,
					     size_t block_alloc,
					     struct mp_block *insert_after)
{}

void mem_pool_init(struct mem_pool *pool, size_t initial_size)
{}

void mem_pool_discard(struct mem_pool *pool, int invalidate_memory)
{}

void *mem_pool_alloc(struct mem_pool *pool, size_t len)
{}

static char *mem_pool_strvfmt(struct mem_pool *pool, const char *fmt,
			      va_list ap)
{}

char *mem_pool_strfmt(struct mem_pool *pool, const char *fmt, ...)
{}

void *mem_pool_calloc(struct mem_pool *pool, size_t count, size_t size)
{}

char *mem_pool_strdup(struct mem_pool *pool, const char *str)
{}

char *mem_pool_strndup(struct mem_pool *pool, const char *str, size_t len)
{}

int mem_pool_contains(struct mem_pool *pool, void *mem)
{}

void mem_pool_combine(struct mem_pool *dst, struct mem_pool *src)
{}