libmetal
Loading...
Searching...
No Matches
alloc.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017, Linaro Limited. and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7/*
8 * @file zephyr/alloc.h
9 * @brief zephyr libmetal memory allocattion definitions.
10 */
11
12#ifndef __METAL_ALLOC__H__
13#error "Include metal/alloc.h instead of metal/zephyr/alloc.h"
14#endif
15
16#ifndef __METAL_ZEPHYR_ALLOC__H__
17#define __METAL_ZEPHYR_ALLOC__H__
18
19#include <kernel.h>
20#include <stdlib.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#if (CONFIG_HEAP_MEM_POOL_SIZE > 0)
27static inline void *metal_allocate_memory(unsigned int size)
28{
29 return k_malloc(size);
30}
31
32static inline void metal_free_memory(void *ptr)
33{
34 k_free(ptr);
35}
36#else
37
38void *metal_zephyr_allocate_memory(unsigned int size);
39void metal_zephyr_free_memory(void *ptr);
40
41static inline void *metal_allocate_memory(unsigned int size)
42{
44}
45
46static inline void metal_free_memory(void *ptr)
47{
49}
50#endif /* CONFIG_HEAP_MEM_POOL_SIZE */
51
52
53#ifdef __cplusplus
54}
55#endif
56
57#endif /* __METAL_ZEPHYR_ALLOC__H__ */
static void * metal_allocate_memory(unsigned int size)
allocate requested memory size return a pointer to the allocated memory
static void metal_free_memory(void *ptr)
free the memory previously allocated
void metal_zephyr_free_memory(void *ptr)
Definition: alloc.c:23
void * metal_zephyr_allocate_memory(unsigned int size)
Definition: alloc.c:17