Merged the ICE branch into the trunk

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@992 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjlib/include/pj/pool.h b/pjlib/include/pj/pool.h
index b3ec5af..e422590 100644
--- a/pjlib/include/pj/pool.h
+++ b/pjlib/include/pj/pool.h
@@ -441,6 +441,8 @@
  * @param size	    the requested size.
  *
  * @return pointer to the allocated memory.
+ *
+ * @see PJ_POOL_ALLOC_TYPE
  */
 PJ_IDECL(void*) pj_pool_alloc( pj_pool_t *pool, pj_size_t size);
 
@@ -460,15 +462,49 @@
 
 
 /**
- * @def pj_pool_zalloc(pj_pool_t *pool, pj_size_t size)
  * Allocate storage from the pool and initialize it to zero.
  *
  * @param pool	    The pool.
  * @param size	    The size to be allocated.
  *
  * @return	    Pointer to the allocated memory.
+ *
+ * @see PJ_POOL_ZALLOC_TYPE
  */
-#define pj_pool_zalloc(pool, size)  pj_pool_calloc(pool, 1, size)
+PJ_INLINE(void*) pj_pool_zalloc(pj_pool_t *pool, pj_size_t size)
+{
+    return pj_pool_calloc(pool, 1, size);
+}
+
+
+/**
+ * This macro allocates memory from the pool and returns the instance of
+ * the specified type. It provides a stricker type safety than pj_pool_alloc()
+ * since the return value of this macro will be type-casted to the specified
+ * type.
+ *
+ * @param pool	    The pool
+ * @param type	    The type of object to be allocated
+ *
+ * @return	    Memory buffer of the specified type.
+ */
+#define PJ_POOL_ALLOC_TYPE(pool,type) \
+	    ((type*)pj_pool_alloc(pool, sizeof(type)))
+
+/**
+ * This macro allocates memory from the pool, zeroes the buffer, and 
+ * returns the instance of the specified type. It provides a stricker type 
+ * safety than pj_pool_zalloc() since the return value of this macro will be 
+ * type-casted to the specified type.
+ *
+ * @param pool	    The pool
+ * @param type	    The type of object to be allocated
+ *
+ * @return	    Memory buffer of the specified type.
+ */
+#define PJ_POOL_ZALLOC_TYPE(pool,type) \
+	    ((type*)pj_pool_zalloc(pool, sizeof(type)))
+
 
 
 /**