/* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later */

#include <assert.h>

#include "libmctp.h"
#include "libmctp-alloc.h"

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "compiler.h"

#ifdef MCTP_DEFAULT_ALLOC
static void *default_msg_malloc(size_t size, void *ctx __unused)
{
	void *ptr = __mctp_alloc(size);
	return ptr;
}

static void default_msg_free(void *msg, void *ctx __unused)
{
	__mctp_free(msg);
}
#endif

struct {
	void *(*m_alloc)(size_t);
	void (*m_free)(void *);
	/* Final argument is ctx */
	void *(*m_msg_alloc)(size_t, void *);
	void (*m_msg_free)(void *, void *);
} alloc_ops = {
#ifdef MCTP_DEFAULT_ALLOC
	malloc,
	free,
	default_msg_malloc,
	default_msg_free,
#endif
};

/* internal-only allocation functions */
void *__mctp_alloc(size_t size)
{
	if (alloc_ops.m_alloc)
		return alloc_ops.m_alloc(size);
	assert(0);
	return NULL;
}

void __mctp_free(void *ptr)
{
	if (alloc_ops.m_free)
		alloc_ops.m_free(ptr);
	else
		assert(0);
}

void *__mctp_msg_alloc(size_t size, struct mctp *mctp)
{
	void *ctx = mctp_get_alloc_ctx(mctp);
	if (alloc_ops.m_msg_alloc)
		return alloc_ops.m_msg_alloc(size, ctx);
	assert(0);
	return NULL;
}

void __mctp_msg_free(void *ptr, struct mctp *mctp)
{
	void *ctx = mctp_get_alloc_ctx(mctp);
	if (alloc_ops.m_msg_free)
		alloc_ops.m_msg_free(ptr, ctx);
}

void mctp_set_alloc_ops(void *(*m_alloc)(size_t), void (*m_free)(void *),
			void *(*m_msg_alloc)(size_t, void *),
			void (*m_msg_free)(void *, void *))
{
	alloc_ops.m_alloc = m_alloc;
	alloc_ops.m_free = m_free;
	alloc_ops.m_msg_alloc = m_msg_alloc;
	alloc_ops.m_msg_free = m_msg_free;
}
