chiark
/
gitweb
/
~mdw
/
mLib
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Another version number bump.
[mLib]
/
sub.c
diff --git
a/sub.c
b/sub.c
index b0d18951d7d848afe5ab65924db01c059cc1d247..57ee19499608cb9e59601ac1f531095f77482ea0 100644
(file)
--- a/
sub.c
+++ b/
sub.c
@@
-1,6
+1,6
@@
/* -*-c-*-
*
/* -*-c-*-
*
- * $Id: sub.c,v 1.
3 1999/05/06 19:51:35
mdw Exp $
+ * $Id: sub.c,v 1.
5 1999/05/19 20:27:11
mdw Exp $
*
* Allocation of known-size blocks
*
*
* Allocation of known-size blocks
*
@@
-30,6
+30,12
@@
/*----- Revision history --------------------------------------------------*
*
* $Log: sub.c,v $
/*----- Revision history --------------------------------------------------*
*
* $Log: sub.c,v $
+ * 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.3 1999/05/06 19:51:35 mdw
* Reformatted the LGPL notice a little bit.
*
@@
-44,7
+50,7
@@
/*----- The big idea ------------------------------------------------------*
*
* This file provides an extra layer over @malloc@. It provides fast
/*----- The big idea ------------------------------------------------------*
*
* This file provides an extra layer over @malloc@. It provides fast
- * turnover for small blocks, and tries to minimi
s
e the per-block overhead.
+ * turnover for small blocks, and tries to minimi
z
e 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
*
* 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
@@
-131,8
+137,8
@@
/*----- Static variables --------------------------------------------------*/
/*----- Static variables --------------------------------------------------*/
-static void *
sub__
bins[SUB_BINS];
-static size_t s
ub__s
izes[SUB_BINS];
+static void *bins[SUB_BINS];
+static size_t sizes[SUB_BINS];
/*----- Main code ---------------------------------------------------------*/
/*----- Main code ---------------------------------------------------------*/
@@
-158,11
+164,11
@@
void *sub_alloc(size_t s)
/* --- If the bin is empty, find some memory --- */
/* --- If the bin is empty, find some memory --- */
- if (!
sub__
bins[bin]) {
+ if (!bins[bin]) {
char *p, *q;
char *p, *q;
- p = xmalloc(s
ub__s
izes[bin]);
- q = p + s
ub__s
izes[bin];
+ p = xmalloc(sizes[bin]);
+ q = p + sizes[bin];
s = SUB_BINSZ(bin);
s = SUB_BINSZ(bin);
@@
-174,13
+180,13
@@
void *sub_alloc(size_t s)
*(void **)q = q + s;
}
*(void **)q = q + s;
}
-
sub__
bins[bin] = p;
+ bins[bin] = p;
}
/* --- Extract the first block in the list --- */
}
/* --- 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);
}
return (p);
}
@@
-201,8
+207,8
@@
void sub_free(void *p, size_t s)
if (bin >= SUB_BINS)
free(p);
else {
if (bin >= SUB_BINS)
free(p);
else {
- *(void **)p =
sub__
bins[bin];
-
sub__
bins[bin] = p;
+ *(void **)p = bins[bin];
+ bins[bin] = p;
}
}
}
}
@@
-212,17
+218,17
@@
void sub_free(void *p, size_t s)
*
* Returns: ---
*
*
* Returns: ---
*
- * Use: Initiali
s
es the magic allocator.
+ * Use: Initiali
z
es the magic allocator.
*/
void sub_init(void)
{
int i;
*/
void sub_init(void)
{
int i;
- /* --- Initiali
s
e the sizes bins --- */
+ /* --- Initiali
z
e the sizes bins --- */
for (i = 1; i < SUB_BINS; i++) {
for (i = 1; i < SUB_BINS; i++) {
- s
ub__s
izes[i] = ((SUB_CHUNK + SUB_BINSZ(i) - 1) /
+ sizes[i] = ((SUB_CHUNK + SUB_BINSZ(i) - 1) /
SUB_BINSZ(i) * SUB_BINSZ(i));
}
}
SUB_BINSZ(i) * SUB_BINSZ(i));
}
}