summaryrefslogtreecommitdiff
path: root/src/common/memory.tpp
blob: af833bcf11b9027d92a2e94015a5bbb4b0ff8827 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#pragma once

#include "memory.hpp"

#include "utils.hpp"

#include <Arduino.h>
#include <stdlib.h>

namespace common
{

template <typename memType>
memType *malloc_s(unsigned int size)
{
	auto *mem = malloc(size);

	if (mem == nullptr)
	{
		Serial.println("Error: Memory allocation failed");
		while (true) {}
	}

	return static_cast<memType *>(mem);
}

} // namespace common