+eina_mempool_calloc
authordiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 2 Dec 2011 15:27:35 +0000 (15:27 +0000)
committerdiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 2 Dec 2011 15:27:35 +0000 (15:27 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@65821 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
NEWS
src/include/eina_inline_mempool.x

index 0d1ccdf..a67006a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 
        * 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
diff --git a/NEWS b/NEWS
index 6f9a0ef..ca39236 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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:
index a67ec3d..c71413e 100644 (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
  *
@@ -104,6 +106,27 @@ eina_mempool_malloc(Eina_Mempool *mp, unsigned int 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.
  *
  * @param mp The mempool.