Index: pjproject/trunk/pjlib/include/pj/pool.h
===================================================================
--- pjproject/trunk/pjlib/include/pj/pool.h	(revision 68)
+++ pjproject/trunk/pjlib/include/pj/pool.h	(revision 69)
@@ -151,7 +151,4 @@
     /** Current capacity allocated by the pool. */
     pj_size_t	    capacity;
-
-    /** Number of memory used/allocated. */
-    pj_size_t	    used_size;
 
     /** Size of memory block to be allocated when the pool runs out of memory */
Index: pjproject/trunk/pjlib/include/pj/pool_i.h
===================================================================
--- pjproject/trunk/pjlib/include/pj/pool_i.h	(revision 68)
+++ pjproject/trunk/pjlib/include/pj/pool_i.h	(revision 69)
@@ -30,9 +30,14 @@
 PJ_IDEF(pj_size_t) pj_pool_get_used_size( pj_pool_t *pool )
 {
-    return pool->used_size;
+    pj_pool_block *b = pool->block_list.next;
+    pj_size_t used_size = sizeof(pj_pool_t);
+    while (b != &pool->block_list) {
+	used_size += (b->cur - b->buf) + sizeof(pj_pool_block);
+	b = b->next;
+    }
+    return used_size;
 }
 
-PJ_IDEF(void*) pj_pool_alloc_from_block( pj_pool_t *pool,
-					 pj_pool_block *block, pj_size_t size )
+PJ_IDEF(void*) pj_pool_alloc_from_block( pj_pool_block *block, pj_size_t size )
 {
     /* The operation below is valid for size==0. 
@@ -41,11 +46,9 @@
      */
     if (size & (PJ_POOL_ALIGNMENT-1)) {
-	size &= ~(PJ_POOL_ALIGNMENT-1);
-	size += PJ_POOL_ALIGNMENT;
+	size = (size + PJ_POOL_ALIGNMENT) & ~(PJ_POOL_ALIGNMENT-1);
     }
     if ((unsigned)(block->end - block->cur) >= size) {
 	void *ptr = block->cur;
 	block->cur += size;
-	pool->used_size += size;
 	return ptr;
     }
@@ -55,6 +58,5 @@
 PJ_IDEF(void*) pj_pool_alloc( pj_pool_t *pool, pj_size_t size)
 {
-    pj_pool_block *block = pool->block_list.next;
-    void *ptr = pj_pool_alloc_from_block(pool, block, size);
+    void *ptr = pj_pool_alloc_from_block(pool->block_list.next, size);
     if (!ptr)
 	ptr = pj_pool_allocate_find(pool, size);
Index: pjproject/trunk/pjlib/src/pj/pool.c
===================================================================
--- pjproject/trunk/pjlib/src/pj/pool.c	(revision 68)
+++ pjproject/trunk/pjlib/src/pj/pool.c	(revision 69)
@@ -46,5 +46,5 @@
 
     LOG((pool->obj_name, "create_block(sz=%u), cur.cap=%u, cur.used=%u", 
-	 size, pool->capacity, pool->used_size));
+	 size, pool->capacity, pj_pool_get_used_size(pool)));
 
     /* Request memory from allocator. */
@@ -58,5 +58,4 @@
     /* Add capacity. */
     pool->capacity += size;
-    pool->used_size += sizeof(pj_pool_block);
 
     /* Set block attribytes. */
@@ -87,5 +86,5 @@
 
     while (block != &pool->block_list) {
-	p = pj_pool_alloc_from_block(pool, block, size);
+	p = pj_pool_alloc_from_block(block, size);
 	if (p != NULL)
 	    return p;
@@ -98,5 +97,5 @@
 	LOG((pool->obj_name, "Can't expand pool to allocate %u bytes "
 	     "(used=%u, cap=%u)",
-	     size, pool->used_size, pool->capacity));
+	     size, pj_pool_get_used_size(pool), pool->capacity));
 	(*pool->callback)(pool, size);
 	return NULL;
@@ -119,5 +118,5 @@
     LOG((pool->obj_name, 
 	 "%u bytes requested, resizing pool by %u bytes (used=%u, cap=%u)",
-	 size, block_size, pool->used_size, pool->capacity));
+	 size, block_size, pj_pool_get_used_size(pool), pool->capacity));
 
     block = pj_pool_create_block(pool, block_size);
@@ -125,5 +124,5 @@
 	return NULL;
 
-    p = pj_pool_alloc_from_block(pool, block, size);
+    p = pj_pool_alloc_from_block(block, size);
     pj_assert(p != NULL);
 #if PJ_DEBUG
@@ -143,16 +142,8 @@
 				pj_pool_callback *callback)
 {
-    pj_pool_block *block;
-
     PJ_CHECK_STACK();
 
     pool->increment_size = increment_size;
     pool->callback = callback;
-    pool->used_size = sizeof(*pool);
-    block = pool->block_list.next;
-    while (block != &pool->block_list) {
-	pool->used_size += sizeof(pj_pool_block);
-	block = block->next;
-    }
 
     if (name) {
@@ -238,5 +229,4 @@
     block->cur = block->buf;
     pool->capacity = block->end - (unsigned char*)pool;
-    pool->used_size = 0;
 }
 
@@ -247,5 +237,6 @@
 {
     LOG((pool->obj_name, "reset(): cap=%d, used=%d(%d%%)", 
-	pool->capacity, pool->used_size, pool->used_size*100/pool->capacity));
+	pool->capacity, pj_pool_get_used_size(pool), 
+	pj_pool_get_used_size(pool)*100/pool->capacity));
 
     reset_pool(pool);
@@ -260,5 +251,6 @@
 
     LOG((pool->obj_name, "destroy(): cap=%d, used=%d(%d%%), block0=%p-%p", 
-	pool->capacity, pool->used_size, pool->used_size*100/pool->capacity,
+	pool->capacity, pj_pool_get_used_size(pool), 
+	pj_pool_get_used_size(pool)*100/pool->capacity,
 	((pj_pool_block*)pool->block_list.next)->buf, 
 	((pj_pool_block*)pool->block_list.next)->end));
Index: pjproject/trunk/pjlib/src/pj/pool_caching.c
===================================================================
--- pjproject/trunk/pjlib/src/pj/pool_caching.c	(revision 68)
+++ pjproject/trunk/pjlib/src/pj/pool_caching.c	(revision 69)
@@ -175,5 +175,6 @@
     /* Reset pool. */
     PJ_LOG(4, (pool->obj_name, "recycle(): cap=%d, used=%d(%d%%)", 
-	       pool->capacity, pool->used_size, pool->used_size*100/pool->capacity));
+	       pool->capacity, pj_pool_get_used_size(pool), 
+	       pj_pool_get_used_size(pool)*100/pool->capacity));
     pj_pool_reset(pool);
 
@@ -208,7 +209,7 @@
 	while (pool != (void*)&cp->used_list) {
 	    PJ_LOG(3,("cachpool", "   %12s: %8d of %8d (%d%%) used", pool->obj_name, 
-				  pool->used_size, pool->capacity,
-				  pool->used_size*100/pool->capacity));
-	    total_used += pool->used_size;
+				  pj_pool_get_used_size(pool), pool->capacity,
+				  pj_pool_get_used_size(pool)*100/pool->capacity));
+	    total_used += pj_pool_get_used_size(pool);
 	    total_capacity += pool->capacity;
 	    pool = pool->next;
