2 ******************************************************************************
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
10 * @brief PiOS memory allocation API
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #ifdef PIOS_TARGET_PROVIDES_FAST_HEAP
31 // relies on pios_general_malloc to perform the allocation (i.e. pios_msheap.c)
32 extern void *pios_general_malloc(void *ptr
, size_t size
, bool fastheap
);
34 void *pios_fastheapmalloc(size_t size
)
36 return pios_general_malloc(NULL
, size
, true);
40 void *pios_malloc(size_t size
)
42 return pios_general_malloc(NULL
, size
, false);
45 void *pios_realloc(__attribute__((unused
)) void *ptr
, __attribute__((unused
)) size_t size
)
47 #ifdef PIOS_INCLUDE_REALLOC
48 return pios_general_malloc(ptr
, size
, false);
51 // Not allowed to use realloc without the proper define PIOS_INCLUDE_REALLOC set
60 void pios_free(void *p
)
65 #else /* ifdef PIOS_TARGET_PROVIDES_FAST_HEAP */
66 // demand to pvPortMalloc implementation
67 void *pios_fastheapmalloc(size_t size
)
69 return pvPortMalloc(size
);
73 void *pios_malloc(size_t size
)
75 return pvPortMalloc(size
);
78 void *pios_realloc(__attribute__((unused
)) void *ptr
, __attribute__((unused
)) size_t size
)
80 #ifdef PIOS_INCLUDE_REALLOC
81 return pvPortMalloc(size
);
84 // Not allowed to use realloc without the proper define PIOS_INCLUDE_REALLOC set
93 void pios_free(void *p
)
98 #endif /* ifdef PIOS_TARGET_PROVIDES_FAST_HEAP */