Index: pjproject/trunk/pjlib/include/pj/pool_alt.h
===================================================================
--- pjproject/trunk/pjlib/include/pj/pool_alt.h	(revision 2122)
+++ pjproject/trunk/pjlib/include/pj/pool_alt.h	(revision 2123)
@@ -23,7 +23,4 @@
 
 
-typedef struct pj_pool_t pj_pool_t;
-
-
 /**
  * The type for function to receive callback from the pool when it is unable
@@ -33,4 +30,23 @@
  */
 typedef void pj_pool_callback(pj_pool_t *pool, pj_size_t size);
+
+struct pj_pool_mem
+{
+    struct pj_pool_mem *next;
+
+    /* data follows immediately */
+};
+
+
+typedef struct pj_pool_t
+{
+    struct pj_pool_mem *first_mem;
+    pj_pool_factory    *factory;
+    char	        obj_name[32];
+    pj_size_t		used_size;
+    pj_pool_callback   *cb;
+} pj_pool_t;
+
+
 
 /**
@@ -106,6 +122,52 @@
 
 
+#define PJ_POOL_ZALLOC_T(pool,type) \
+	    ((type*)pj_pool_zalloc(pool, sizeof(type)))
+#define PJ_POOL_ALLOC_T(pool,type) \
+	    ((type*)pj_pool_alloc(pool, sizeof(type)))
+#ifndef PJ_POOL_ALIGNMENT
+#   define PJ_POOL_ALIGNMENT    4
+#endif
+
+/**
+ * This structure declares pool factory interface.
+ */
+typedef struct pj_pool_factory_policy
+{
+    /**
+     * Allocate memory block (for use by pool). This function is called
+     * by memory pool to allocate memory block.
+     * 
+     * @param factory	Pool factory.
+     * @param size	The size of memory block to allocate.
+     *
+     * @return		Memory block.
+     */
+    void* (*block_alloc)(pj_pool_factory *factory, pj_size_t size);
+
+    /**
+     * Free memory block.
+     *
+     * @param factory	Pool factory.
+     * @param mem	Memory block previously allocated by block_alloc().
+     * @param size	The size of memory block.
+     */
+    void (*block_free)(pj_pool_factory *factory, void *mem, pj_size_t size);
+
+    /**
+     * Default callback to be called when memory allocation fails.
+     */
+    pj_pool_callback *callback;
+
+    /**
+     * Option flags.
+     */
+    unsigned flags;
+
+} pj_pool_factory_policy;
+
 typedef struct pj_pool_factory
 {
+    pj_pool_factory_policy policy;
     int dummy;
 } pj_pool_factory;
@@ -121,5 +183,4 @@
 #define pj_pool_factory_dump(pf, detail)
 
-
 #endif	/* __PJ_POOL_ALT_H__ */
 
Index: pjproject/trunk/pjlib/src/pj/pool_buf.c
===================================================================
--- pjproject/trunk/pjlib/src/pj/pool_buf.c	(revision 2122)
+++ pjproject/trunk/pjlib/src/pj/pool_buf.c	(revision 2123)
@@ -81,4 +81,5 @@
 					 pj_size_t size)
 {
+#if PJ_HAS_POOL_ALT_API == 0
     struct creation_param param;
     long align_diff;
@@ -106,4 +107,8 @@
     return pj_pool_create_int(&stack_based_factory, name, size, 0, 
 			      pj_pool_factory_default_policy.callback);
+#else
+    PJ_UNUSED_ARG(buf);
+    return pj_pool_create(NULL, name, size, size, NULL);
+#endif
 }
 
Index: pjproject/trunk/pjlib/src/pj/pool_dbg.c
===================================================================
--- pjproject/trunk/pjlib/src/pj/pool_dbg.c	(revision 2122)
+++ pjproject/trunk/pjlib/src/pj/pool_dbg.c	(revision 2123)
@@ -20,5 +20,5 @@
 #include <pj/string.h>
 
-#if PJ_POOL_DEBUG
+#if PJ_HAS_POOL_ALT_API
 
 #if PJ_HAS_MALLOC_H
@@ -42,22 +42,12 @@
 
 
-struct pj_pool_mem
-{
-    struct pj_pool_mem *next;
-
-    /* data follows immediately */
-};
-
-
-struct pj_pool_t
-{
-    struct pj_pool_mem *first_mem;
-    pj_size_t		used_size;
-    pj_pool_callback   *cb;
-};
-
 
 int PJ_NO_MEMORY_EXCEPTION;
 
+
+PJ_DEF(int) pj_NO_MEMORY_EXCEPTION()
+{
+    return PJ_NO_MEMORY_EXCEPTION;
+}
 
 /* Create pool */
@@ -74,5 +64,4 @@
     PJ_UNUSED_ARG(line);
     PJ_UNUSED_ARG(factory);
-    PJ_UNUSED_ARG(name);
     PJ_UNUSED_ARG(initial_size);
     PJ_UNUSED_ARG(increment_size);
@@ -82,4 +71,12 @@
 	return NULL;
 
+    if (name) {
+	pj_ansi_strncpy(pool->obj_name, name, sizeof(pool->obj_name));
+	pool->obj_name[sizeof(pool->obj_name)-1] = '\0';
+    } else {
+	strcpy(pool->obj_name, "altpool");
+    }
+
+    pool->factory = NULL;
     pool->first_mem = NULL;
     pool->used_size = 0;
@@ -185,7 +182,8 @@
 				  pj_pool_t *pool, pj_size_t sz)
 {
-    return pj_pool_calloc_imp(file, line, pool, 1, sz);
+    return pj_pool_calloc_imp(file, line, pool, 1, sz); 
 }
 
 
-#endif	/* PJ_POOL_DEBUG */
+
+#endif	/* PJ_HAS_POOL_ALT_API */
