aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eina/src/include/eina_inline_mempool.x
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/eina/src/include/eina_inline_mempool.x')
-rw-r--r--libraries/eina/src/include/eina_inline_mempool.x49
1 files changed, 35 insertions, 14 deletions
diff --git a/libraries/eina/src/include/eina_inline_mempool.x b/libraries/eina/src/include/eina_inline_mempool.x
index a67ec3d..729a669 100644
--- a/libraries/eina/src/include/eina_inline_mempool.x
+++ b/libraries/eina/src/include/eina_inline_mempool.x
@@ -19,6 +19,8 @@
19#ifndef EINA_INLINE_MEMPOOL_X_ 19#ifndef EINA_INLINE_MEMPOOL_X_
20#define EINA_INLINE_MEMPOOL_X_ 20#define EINA_INLINE_MEMPOOL_X_
21 21
22#include <string.h>
23
22/** 24/**
23 * @addtogroup Eina_Memory_Pool_Group Memory Pool 25 * @addtogroup Eina_Memory_Pool_Group Memory Pool
24 * 26 *
@@ -67,17 +69,16 @@ struct _Eina_Mempool
67}; 69};
68 70
69/** 71/**
70 * @brief Re-allocate a amount memory by the given mempool. 72 * @brief Re-allocate an amount memory by the given mempool.
71 * 73 *
72 * @param mp The mempool. 74 * @param mp The mempool.
73 * @param element The element to re-allocate. 75 * @param element The element to re-allocate.
74 * @param size The size in bytes to re-allocate. 76 * @param size The size in bytes to re-allocate.
75 * @return The newly re-allocated data. 77 * @return The newly re-allocated data.
76 * 78 *
77 * This function re-allocates @p element with @p size bytes, using the 79 * This function re-allocates and returns @p element with @p size bytes using the
78 * mempool @p mp and returns the allocated data. If not used anymore, 80 * mempool @p mp. If not used anymore, the data must be freed with eina_mempool_free().
79 * the data must be freed with eina_mempool_free(). No check is done 81 * @warning No checks are done for @p mp.
80 * on @p mp, so it must be a valid mempool.
81 */ 82 */
82static inline void * 83static inline void *
83eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size) 84eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size)
@@ -86,16 +87,15 @@ eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size)
86} 87}
87 88
88/** 89/**
89 * @brief Allocate a amount memory by the given mempool. 90 * @brief Allocate memory using the given mempool.
90 * 91 *
91 * @param mp The mempool. 92 * @param mp The mempool.
92 * @param size The size in bytes to allocate. 93 * @param size The size in bytes to allocate.
93 * @return The newly allocated data. 94 * @return The newly allocated data.
94 * 95 *
95 * This function allocates @p size bytes, using the mempool @p mp and 96 * This function allocates and returns @p size bytes using the mempool @p mp.
96 * returns the allocated data. If not used anymore, the data must be 97 * If not used anymore, the data must be freed with eina_mempool_free().
97 * freed with eina_mempool_free(). No check is done on @p mp, so it 98 * @warning No checks are done for @p mp.
98 * must be a valid mempool.
99 */ 99 */
100static inline void * 100static inline void *
101eina_mempool_malloc(Eina_Mempool *mp, unsigned int size) 101eina_mempool_malloc(Eina_Mempool *mp, unsigned int size)
@@ -104,15 +104,36 @@ eina_mempool_malloc(Eina_Mempool *mp, unsigned int size)
104} 104}
105 105
106/** 106/**
107 * @brief Free the allocated ressources by the given mempool. 107 * @brief Allocate and zero memory using the given mempool.
108 *
109 * @param mp The mempool.
110 * @param size The size in bytes to allocate.
111 * @return The newly allocated data.
112 *
113 * This function allocates, zeroes, and returns @p size bytes using the mempool @p mp.
114 * If not used anymore, the data must be freed with eina_mempool_free().
115 * @warning No checks are done for @p mp.
116 * @since 1.2
117 */
118static inline void *
119eina_mempool_calloc(Eina_Mempool *mp, unsigned int size)
120{
121 void *r = mp->backend.alloc(mp->backend_data, size);
122 if (!r) return NULL;
123 memset(r, 0, size);
124 return r;
125}
126
127/**
128 * @brief Free resources previously allocated by the given mempool.
108 * 129 *
109 * @param mp The mempool. 130 * @param mp The mempool.
110 * @param element The data to free. 131 * @param element The data to free.
111 * 132 *
112 * This function frees @p element allocated by @p mp. @p element must 133 * This function frees @p element allocated by @p mp. @p element must
113 * have been obtained by eina_mempool_malloc() or 134 * have been obtained from eina_mempool_malloc(), eina_mempool_calloc(), or
114 * eina_mempool_realloc(). No check is done on @p mp, so it must be a 135 * eina_mempool_realloc().
115 * valid mempool. 136 * @warning No checks are done for @p mp.
116 */ 137 */
117static inline void 138static inline void
118eina_mempool_free(Eina_Mempool *mp, void *element) 139eina_mempool_free(Eina_Mempool *mp, void *element)