+mbinit()
+{
+
+ if (m_clalloc(4, MPG_MBUFS) == 0)
+ goto bad;
+ if (m_clalloc(32, MPG_CLUSTERS) == 0)
+ goto bad;
+ return;
+bad:
+ panic("mbinit");
+}
+
+caddr_t
+m_clalloc(ncl, how)
+ register int ncl;
+ int how;
+{
+ int npg, mbx;
+ register struct mbuf *m;
+ register int i;
+ int s;
+
+ npg = ncl * CLSIZE;
+ s = splimp(); /* careful: rmalloc isn't reentrant */
+ mbx = rmalloc(mbmap, npg);
+ splx(s);
+ if (mbx == 0)
+ return (0);
+ m = cltom(mbx / CLSIZE);
+ if (memall(&Mbmap[mbx], npg, proc, CSYS) == 0)
+ return (0);
+ vmaccess(&Mbmap[mbx], (caddr_t)m, npg);
+ switch (how) {
+
+ case MPG_CLUSTERS:
+ s = splimp();
+ for (i = 0; i < ncl; i++) {
+ m->m_off = 0;
+ m->m_next = mclfree;
+ mclfree = m;
+ m += CLBYTES / sizeof (*m);
+ mbstat.m_clfree++;
+ }
+ mbstat.m_clusters += ncl;
+ splx(s);
+ break;
+
+ case MPG_MBUFS:
+ for (i = ncl * CLBYTES / sizeof (*m); i > 0; i--) {
+ m->m_off = 0;
+ m->m_free = 0;
+ mbstat.m_mbufs++;
+ (void) m_free(m);
+ m++;
+ }
+ break;
+ }
+ return ((caddr_t)m);
+}
+
+m_pgfree(addr, n)
+ caddr_t addr;
+ int n;
+{
+
+#ifdef lint
+ addr = addr; n = n;
+#endif
+}
+
+m_expand()
+{
+
+ if (m_clalloc(1, MPG_MBUFS) == 0)
+ goto steal;
+ return (1);
+steal:
+ /* should ask protocols to free code */
+ return (0);
+}
+
+/* NEED SOME WAY TO RELEASE SPACE */
+
+/*
+ * Space allocation routines.
+ * These are also available as macros
+ * for critical paths.
+ */