aboutsummaryrefslogtreecommitdiff
path: root/lib/pbdrv/pb-mem.c
blob: 2ef44194486b6524b514a5eb78b44069a18c9fca (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
28
29
30
31
#include "pb-mem.h"

#ifdef PB_TARGET_FREERTOS
#include <FreeRTOS.h>
#define _pb_free vPortFree
#define _pb_malloc pvPortMalloc
#endif

#ifdef PB_TARGET_STDLIB
#include <stdlib.h>
#define _pb_free free
#define _pb_malloc malloc
#define _pb_realloc realloc
#endif

inline void * pb_malloc(size_t sz) {
	return _pb_malloc(sz);
}

inline void pb_free(void * ptr) {
	_pb_free(ptr);
}

inline void * pb_realloc(void * ptr, size_t sz) {
#ifdef _pb_realloc
	return _pb_realloc(ptr, sz);
#else
	return NULL; // shit out of luck
#endif
}