diff -ru apr/include/apr_sms.h apr-sms/include/apr_sms.h
--- apr/include/apr_sms.h	Sun Jun 10 20:22:01 2001
+++ apr-sms/include/apr_sms.h	Thu Jun 14 11:35:43 2001
@@ -77,6 +77,13 @@
 #define APR_CHILD_CLEANUP     0x0001
 #define APR_PARENT_CLEANUP    0x0002
 
+
+/* Alignment macros for sms implementors */
+#define APR_SMS_ALIGN(size, boundary) \
+    ((size) + (((boundary) - ((size) & ((boundary) - 1))) & ((boundary) - 1)))
+#define APR_SMS_ALIGN_DEFAULT(size) APR_SMS_ALIGN(size, 8)
+            
+    
 /**
  * @package APR memory system
  */
diff -ru apr/memory/unix/apr_sms_blocks.c apr-sms/memory/unix/apr_sms_blocks.c
--- apr/memory/unix/apr_sms_blocks.c	Wed Jun 13 21:39:37 2001
+++ apr-sms/memory/unix/apr_sms_blocks.c	Thu Jun 14 12:07:02 2001
@@ -82,6 +82,9 @@
     void *nxt;
 };
 
+#define SIZEOF_BLOCK_T  APR_SMS_ALIGN_DEFAULT(sizeof(block_t))
+#define BLOCK_T(mem)    ((block_t *)(mem))
+    
 typedef struct apr_sms_blocks_t apr_sms_blocks_t;
 struct apr_sms_blocks_t
 {
@@ -90,32 +93,45 @@
     void                *ptr;
     void                *endp;
     block_t             *free_list;
+    block_t             *external_list;
     apr_lock_t          *lock;
 };
 
-#define SIZEOF_BLOCKS_T (sizeof(apr_sms_blocks_t) + \
-                        ((0x8 - (sizeof(apr_sms_blocks_t) & 0x7)) & 0x7))
-#define BLOCKS_T(sms)   ((apr_sms_blocks_t *)sms)
+#define SIZEOF_BLOCKS_T APR_SMS_ALIGN_DEFAULT(sizeof(apr_sms_blocks_t))
+#define BLOCKS_T(sms)   ((apr_sms_blocks_t *)(sms))
 
 static void *apr_sms_blocks_malloc(apr_sms_t *sms,
                                    apr_size_t size)
 {
     void *mem;
     
-    if (size > BLOCKS_T(sms)->block_sz)
-        return NULL;
-
-    if ((mem = BLOCKS_T(sms)->free_list) != NULL) {
-        BLOCKS_T(sms)->free_list = ((block_t*)mem)->nxt;
-        return mem;
+    if (size <= BLOCKS_T(sms)->block_sz) {
+        if ((mem = BLOCKS_T(sms)->free_list) != NULL) {
+            BLOCKS_T(sms)->free_list = ((block_t*)mem)->nxt;
+            return mem;
+        }
+    
+        mem = BLOCKS_T(sms)->ptr;
+        BLOCKS_T(sms)->ptr += BLOCKS_T(sms)->block_sz;
+
+        if (BLOCKS_T(sms)->ptr <= BLOCKS_T(sms)->endp)
+            return mem;
+        
+        BLOCKS_T(sms)->ptr = BLOCKS_T(sms)->endp;
+        size = BLOCKS_T(sms)->block_sz;
     }
-    
-    mem = BLOCKS_T(sms)->ptr;
-    BLOCKS_T(sms)->ptr += BLOCKS_T(sms)->block_sz;
 
-    if (BLOCKS_T(sms)->ptr > BLOCKS_T(sms)->endp)
+    size = APR_SMS_ALIGN_DEFAULT(size) + SIZEOF_BLOCK_T;
+
+    mem = apr_sms_malloc(sms->parent, size);
+    if (!mem)
         return NULL;
 
+    BLOCK_T(mem)->nxt = BLOCKS_T(sms)->external_list;
+    BLOCKS_T(sms)->external_list = mem;
+
+    (char *)mem += SIZEOF_BLOCK_T;
+
     return mem;
 }
     
@@ -124,22 +140,36 @@
 {
     void *mem;
     
-    if (size > BLOCKS_T(sms)->block_sz)
-        return NULL;
-
-    if ((mem = BLOCKS_T(sms)->free_list) != NULL) {
-        BLOCKS_T(sms)->free_list = ((block_t*)mem)->nxt;
-        return mem;
+    if (size <= BLOCKS_T(sms)->block_sz) {
+        if ((mem = BLOCKS_T(sms)->free_list) != NULL) {
+            BLOCKS_T(sms)->free_list = ((block_t*)mem)->nxt;
+            memset(mem, '\0', BLOCKS_T(sms)->block_sz);
+            return mem;
+        }
+    
+        mem = BLOCKS_T(sms)->ptr;
+        BLOCKS_T(sms)->ptr += BLOCKS_T(sms)->block_sz;
+
+        if (BLOCKS_T(sms)->ptr <= BLOCKS_T(sms)->endp) {
+            memset(mem, '\0', BLOCKS_T(sms)->block_sz);
+            return mem;
+        }
+        
+        BLOCKS_T(sms)->ptr = BLOCKS_T(sms)->endp;
+        size = BLOCKS_T(sms)->block_sz;
     }
-    
-    mem = BLOCKS_T(sms)->ptr;
-    BLOCKS_T(sms)->ptr += BLOCKS_T(sms)->block_sz;
 
-    if (BLOCKS_T(sms)->ptr > BLOCKS_T(sms)->endp)
+    size = APR_SMS_ALIGN_DEFAULT(size) + SIZEOF_BLOCK_T;
+
+    mem = apr_sms_calloc(sms->parent, size);
+    if (!mem)
         return NULL;
 
-    memset(mem, '\0', BLOCKS_T(sms)->block_sz);
-    
+    BLOCK_T(mem)->nxt = BLOCKS_T(sms)->external_list;
+    BLOCKS_T(sms)->external_list = mem;
+
+    (char *)mem += SIZEOF_BLOCK_T;
+
     return mem;
 }
 
@@ -154,14 +184,28 @@
 
 static apr_status_t apr_sms_blocks_reset(apr_sms_t *sms)
 {
+    block_t *block;
+    
     BLOCKS_T(sms)->ptr = (char *)sms + SIZEOF_BLOCKS_T;
     BLOCKS_T(sms)->free_list = NULL;
+
+    while ((block = BLOCKS_T(sms)->external_list) != NULL) {
+        BLOCKS_T(sms)->external_list = block->nxt;
+        apr_sms_free(sms->parent, block);
+    }
     
     return APR_SUCCESS;
 }
 
 static apr_status_t apr_sms_blocks_destroy(apr_sms_t *sms)
 {
+    block_t *block;
+    
+    while ((block = BLOCKS_T(sms)->external_list) != NULL) {
+        BLOCKS_T(sms)->external_list = block->nxt;
+        apr_sms_free(sms->parent, block);
+    }
+    
     return apr_sms_free(sms->parent, sms);
 }
 
@@ -188,11 +232,9 @@
     new_sms->destroy_fn     = apr_sms_blocks_destroy;
     new_sms->identity       = module_identity;
 
-    BLOCKS_T(new_sms)->ptr = (char *)new_sms + SIZEOF_BLOCKS_T;
-    BLOCKS_T(new_sms)->endp = (char *)new_sms + SIZE_TO_MALLOC;
-    
-    BLOCKS_T(new_sms)->block_sz = block_size +
-                                 ((0x8 - (block_size & 0x7)) & 0x7);
+    BLOCKS_T(new_sms)->ptr      = (char *)new_sms + SIZEOF_BLOCKS_T;
+    BLOCKS_T(new_sms)->endp     = (char *)new_sms + SIZE_TO_MALLOC;
+    BLOCKS_T(new_sms)->block_sz = APR_SMS_ALIGN_DEFAULT(block_size);
 
     /* We are normally single threaded so no lock */
     
