+eina_mempool_calloc

SVN revision: 65821
This commit is contained in:
Mike Blumenkrantz 2011-12-02 15:27:35 +00:00
parent ce0bd5f36e
commit afdbaf8651
3 changed files with 37 additions and 0 deletions

View File

@ -147,3 +147,7 @@
* Add new hash function eina_hash_murmur3 that should be better at
hashing strings.
2011-12-02 Mike Blumenkrantz (discomfitor/zmike)
* Add eina_mempool_calloc for returning zeroed memory

View File

@ -1,3 +1,13 @@
Eina 1.2.0
Changes since Eina 1.1.0:
-------------------------
Additions:
* eina_mempool_calloc
Eina 1.1.0
Changes since Eina 1.0.0:

View File

@ -19,6 +19,8 @@
#ifndef EINA_INLINE_MEMPOOL_X_
#define EINA_INLINE_MEMPOOL_X_
#include <string.h>
/**
* @addtogroup Eina_Memory_Pool_Group Memory Pool
*
@ -103,6 +105,27 @@ eina_mempool_malloc(Eina_Mempool *mp, unsigned int size)
return mp->backend.alloc(mp->backend_data, size);
}
/**
* @brief Allocate and zero a amount memory by the given mempool.
*
* @param mp The mempool.
* @param size The size in bytes to allocate.
* @return The newly allocated data.
*
* This function allocates @p size bytes, using the mempool @p mp and
* returns the allocated data after zeroing it. If not used anymore,
* the data must be freed with eina_mempool_free(). No check is done on @p mp,
* so it must be a valid mempool.
*/
static inline void *
eina_mempool_calloc(Eina_Mempool *mp, unsigned int size)
{
void *r = mp->backend.alloc(mp->backend_data, size);
if (!r) return NULL;
memset(r, 0, size);
return r;
}
/**
* @brief Free the allocated ressources by the given mempool.
*