chiark / gitweb /
Interface change to make the `conn' selector useful for generic stream
[mLib] / sub.c
diff --git a/sub.c b/sub.c
index 2f0fed3c1161ab5eaf122f36776c474d62c2d14e..57ee19499608cb9e59601ac1f531095f77482ea0 100644 (file)
--- a/sub.c
+++ b/sub.c
@@ -1,43 +1,56 @@
 /* -*-c-*-
  *
- * $Id: sub.c,v 1.1 1998/06/17 23:44:42 mdw Exp $
+ * $Id: sub.c,v 1.5 1999/05/19 20:27:11 mdw Exp $
  *
  * Allocation of known-size blocks
  *
  * (c) 1998 Straylight/Edgeware
  */
 
-/*----- Licensing notice --------------------------------------------------*
+/*----- Licensing notice --------------------------------------------------* 
  *
  * This file is part of the mLib utilities library.
  *
  * mLib is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
+ * it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ * 
  * mLib is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with mLib; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * GNU Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Library General Public
+ * License along with mLib; if not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
  */
 
 /*----- Revision history --------------------------------------------------*
  *
  * $Log: sub.c,v $
- * Revision 1.1  1998/06/17 23:44:42  mdw
- * Initial revision
+ * Revision 1.5  1999/05/19 20:27:11  mdw
+ * Change naming to match newer mLib conventions.
+ *
+ * Revision 1.4  1999/05/13 22:48:55  mdw
+ * Change `-ise' to `-ize' throughout.
+ *
+ * Revision 1.3  1999/05/06 19:51:35  mdw
+ * Reformatted the LGPL notice a little bit.
+ *
+ * Revision 1.2  1999/05/05 18:50:31  mdw
+ * Change licensing conditions to LGPL.
+ *
+ * Revision 1.1.1.1  1998/06/17 23:44:42  mdw
+ * Initial version of mLib
  *
  */
 
 /*----- The big idea ------------------------------------------------------*
  *
  * This file provides an extra layer over @malloc@.  It provides fast
- * turnover for small blocks, and tries to minimise the per-block overhead.
+ * turnover for small blocks, and tries to minimize the per-block overhead.
  *
  * To do its job, @alloc@ must place an extra restriction on you: you must
  * know the size of a block when you free it.  Usually you'll have this
 
 /*----- Static variables --------------------------------------------------*/
 
-static void *sub__bins[SUB_BINS];
-static size_t sub__sizes[SUB_BINS];
+static void *bins[SUB_BINS];
+static size_t sizes[SUB_BINS];
 
 /*----- Main code ---------------------------------------------------------*/
 
@@ -151,11 +164,11 @@ void *sub_alloc(size_t s)
 
   /* --- If the bin is empty, find some memory --- */
 
-  if (!sub__bins[bin]) {
+  if (!bins[bin]) {
     char *p, *q;
 
-    p = xmalloc(sub__sizes[bin]);
-    q = p + sub__sizes[bin];
+    p = xmalloc(sizes[bin]);
+    q = p + sizes[bin];
 
     s = SUB_BINSZ(bin);
 
@@ -167,13 +180,13 @@ void *sub_alloc(size_t s)
       *(void **)q = q + s;
     }
 
-    sub__bins[bin] = p;
+    bins[bin] = p;
   }
 
   /* --- Extract the first block in the list --- */
 
-  p = sub__bins[bin];
-  sub__bins[bin] = *(void **)p;
+  p = bins[bin];
+  bins[bin] = *(void **)p;
   return (p);
 }
 
@@ -194,8 +207,8 @@ void sub_free(void *p, size_t s)
   if (bin >= SUB_BINS)
     free(p);
   else {
-    *(void **)p = sub__bins[bin];
-    sub__bins[bin] = p;
+    *(void **)p = bins[bin];
+    bins[bin] = p;
   }
 }
 
@@ -205,17 +218,17 @@ void sub_free(void *p, size_t s)
  *
  * Returns:     ---
  *
- * Use:         Initialises the magic allocator.
+ * Use:         Initializes the magic allocator.
  */
 
 void sub_init(void)
 {
   int i;
 
-  /* --- Initialise the sizes bins --- */
+  /* --- Initialize the sizes bins --- */
 
   for (i = 1; i < SUB_BINS; i++) {
-    sub__sizes[i] = ((SUB_CHUNK + SUB_BINSZ(i) - 1) /
+    sizes[i] = ((SUB_CHUNK + SUB_BINSZ(i) - 1) /
                     SUB_BINSZ(i) * SUB_BINSZ(i));
   }
 }