1 /*------------------------------------------------------------------------------------------------*/
2 /* UNICENS V2.1.0-3491 */
3 /* Copyright (c) 2017 Microchip Technology Germany II GmbH & Co. KG. */
5 /* This program is free software: you can redistribute it and/or modify */
6 /* it under the terms of the GNU General Public License as published by */
7 /* the Free Software Foundation, either version 2 of the License, or */
8 /* (at your option) any later version. */
10 /* This program is distributed in the hope that it will be useful, */
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
13 /* GNU General Public License for more details. */
15 /* You should have received a copy of the GNU General Public License */
16 /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 /* You may also obtain this software under a propriety license from Microchip. */
19 /* Please contact Microchip for further information. */
20 /*------------------------------------------------------------------------------------------------*/
24 * \brief Declaration of internal memory buffer
26 * \cond UCS_INTERNAL_DOC
27 * \addtogroup G_MEMORY
34 /*------------------------------------------------------------------------------------------------*/
36 /*------------------------------------------------------------------------------------------------*/
37 #include "ucs_memory_pb.h"
44 /*------------------------------------------------------------------------------------------------*/
45 /* IAllocator Types */
46 /*------------------------------------------------------------------------------------------------*/
47 /*! \brief Callback function which frees memory
48 * \param allocator Reference to the Mem_Allocator_t object
49 * \param mem_ptr Reference to memory chunk
50 * \param mem_info_ptr Customer specific information needed to free
51 * the related memory chunk
53 typedef void (*Mem_Free_t)(void *allocator, void* mem_ptr, void* mem_info_ptr);
55 /*! \brief Callback function which allocated memory
56 * \param allocator Reference to the Mem_Allocator_t object
57 * \param size Size of the demanded memory chunk
58 * \param mem_info_ptr Customer specific information needed to free
59 * the related memory chunk
60 * \return Reference to a memory chunk with a minimum size of \c size.
63 typedef void* (*Mem_Allocate_t)(void *allocator, uint16_t size, void** mem_info_ptr);
65 /*------------------------------------------------------------------------------------------------*/
66 /* Interface IAllocator */
67 /*------------------------------------------------------------------------------------------------*/
68 /*! \brief Interface which is needed to be implemented by a memory allocator */
69 typedef struct IAllocator_
71 void* base; /*!< Reference to the base class */
72 Mem_Allocate_t allocate_fptr; /*!< Callback function required to allocate memory */
73 Mem_Free_t free_fptr; /*!< Callback function required to free memory */
78 /*------------------------------------------------------------------------------------------------*/
80 /*------------------------------------------------------------------------------------------------*/
81 /*! \brief Memory chunk comprising non public fields */
82 typedef struct Mem_IntBuffer_
84 Ucs_Mem_Buffer_t public_buffer; /*!< \brief Public attributes of memory buffer
85 * \details This has to be the first member in this
88 IAllocator *allocator_ptr; /*!< \brief Reference to the allocator which is
89 * required to free the memory chunk
91 void *mem_info_ptr; /*!< \brief Customer specific information needed to
92 * free the related memory chunk
100 #endif /* #ifndef UCS_MEMORY_H */
107 /*------------------------------------------------------------------------------------------------*/
109 /*------------------------------------------------------------------------------------------------*/