Index: src/ircd.c
===================================================================
RCS file: /cvsroot/ircd-hybrid-6/src/ircd.c,v
retrieving revision 1.146
diff -u -r1.146 ircd.c
--- src/ircd.c	2001/07/18 02:15:26	1.146
+++ src/ircd.c	2001/09/27 16:06:51
@@ -354,7 +354,7 @@
     }
   }
 }
-
+static time_t next_gc = 0;
 static time_t io_loop(time_t delay)
 {
   static char   to_send[200];
@@ -362,7 +362,6 @@
   static long   lastrecvK = 0;
   static int    lrv       = 0;
   time_t        lasttimeofday;
-
   lasttimeofday = CurrentTime;
   if ((CurrentTime = time(NULL)) == -1)
     {
@@ -370,6 +369,10 @@
       sendto_ops("Clock Failure (%d), TS can be corrupted", errno);
       restart("Clock Failure");
     }
+  if(!next_gc)
+    {
+  	next_gc = CurrentTime + 600;
+    }

   if (CurrentTime < lasttimeofday)
     {
@@ -543,11 +546,17 @@
   ** -avalon
   */
   flush_connections(0);
-
+
 #ifndef NO_PRIORITY
   fdlist_check(CurrentTime);
 #endif

+  if(CurrentTime >= next_gc)
+  {
+     block_garbage_collect();
+     next_gc = CurrentTime + 600;
+  }
+
   return delay;

 }
@@ -731,7 +741,12 @@
    * set initialVMTop before we allocate any memory
    */
   initialVMTop = get_vm_top();
-
+
+  /*
+   * Initialize the Blockheap allocator
+   */
+  initBlockHeap();
+
   ServerRunning = 0;
   memset(&me, 0, sizeof(me));
   GlobalClientList = &me;       /* Pointer to beginning of Client list */
Index: src/blalloc.c
===================================================================
RCS file: /cvsroot/ircd-hybrid-6/src/blalloc.c,v
retrieving revision 1.19
diff -u -r1.19 blalloc.c
--- src/blalloc.c	2001/07/18 02:15:23	1.19
+++ src/blalloc.c	2001/09/27 16:06:51
@@ -13,7 +13,7 @@

 #include <string.h>
 #include <stdlib.h>
-
+#include <sys/mman.h>
 #ifdef DEBUG_BLOCK_ALLOCATOR
 #include "send.h"           /* sendto_ops */

@@ -22,9 +22,38 @@
 #endif

 static int newblock(BlockHeap *bh);
+static void *get_block(size_t size);

 extern void outofmemory(void);      /* defined in list.c */

+
+
+#ifndef MAP_ANON
+int zero_fd = -1;
+void initBlockHeap(void)
+{
+    zero_fd = open("/dev/zero", O_RDWR);
+    if (zero_fd < 0)
+        outofmemory();
+}
+
+static void *get_block(size_t size)
+{
+    return (mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, zero_fd, 0));
+}
+#else
+void initBlockHeap(void)
+{
+    return;
+}
+
+static void *get_block(size_t size)
+{
+    return (mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0));
+}
+#endif
+
+
 /* ************************************************************************ */
 /* FUNCTION DOCUMENTATION:                                                  */
 /*    newblock                                                              */
@@ -57,7 +86,8 @@
      }

    /* Now allocate the memory for the elems themselves. */
-   b->elems = (void *) MyMalloc ((bh->elemsPerBlock + 1) * bh->elemSize);
+
+   b->elems = get_block((bh->elemsPerBlock + 1) * bh->elemSize);
    if (b->elems == NULL)
      {
        free(b->allocMap);
@@ -336,7 +366,7 @@
       if (i == bh->numlongs)
         {
           /* This entire block is free.  Remove it. */
-          free(walker->elems);
+          munmap(walker->elems, (bh->elemsPerBlock + 1) * bh->elemSize);
           free(walker->allocMap);

           if (last)
@@ -384,7 +414,7 @@
    for (walker = bh->base; walker != NULL; walker = next)
      {
        next = walker->next;
-       free(walker->elems);
+       munmap(walker->elems, (bh->elemsPerBlock + 1) * bh->elemSize);
        free(walker->allocMap);
        free(walker);
      }
Index: include/blalloc.h
===================================================================
RCS file: /cvsroot/ircd-hybrid-6/include/blalloc.h,v
retrieving revision 1.4
diff -u -r1.4 blalloc.h
--- include/blalloc.h	1999/07/21 05:44:59	1.4
+++ include/blalloc.h	2001/09/27 16:06:51
@@ -62,7 +62,7 @@
 extern void*      BlockHeapAlloc(BlockHeap *bh);
 extern int        BlockHeapFree(BlockHeap *bh, void *ptr);
 extern int        BlockHeapGarbageCollect(BlockHeap *);
-
+extern void	  initBlockHeap(void);
 extern void       BlockHeapCountMemory(BlockHeap *bh,int *, int *);

 #define BlockHeapALLOC(bh, type)  ((type*) BlockHeapAlloc(bh))
