#include <stdlib.h>
#include <memory.h>
#include "em_ta.h"

void *em_calloc(unsigned int count, unsigned int size)
{
	void *p;

	if (size * count == 0) {
		LOGI("size * count(%u,%u) is 0\n", size, count);
		return NULL;
	}

	p = calloc(size, count);
	if (p == NULL)
		LOGI("Failed to allocate memory(size = %u)\n", count * size);

	return p;
}

void *em_malloc(unsigned int size)
{
	void *buf = NULL;

	if (size == 0) {
		LOGI("size is 0\n");
		return NULL;
	}

	buf = calloc(size, 1);
	if (buf == NULL) {
		LOGE("Failed to allocate memory\n");
		return NULL;
	}

	return buf;
}

void em_free(void *buf)
{
	if (buf)
		free(buf);
}
