diff options
author | julian <julian@FreeBSD.org> | 1999-10-25 23:20:15 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 1999-10-25 23:20:15 +0000 |
commit | feb9306786b253f27c2d97a6a5bed74154eaf59a (patch) | |
tree | e375e9421dedec8d0cca4ecfa79dc5a4e1478a25 | |
parent | 77334da0994acc658fb1696b98bf6db110b97684 (diff) | |
download | FreeBSD-src-feb9306786b253f27c2d97a6a5bed74154eaf59a.zip FreeBSD-src-feb9306786b253f27c2d97a6a5bed74154eaf59a.tar.gz |
Abstract out some functionality into some more Macro's and eliminate
duplicate code.
Reviwed by: Archie Cobbs <archie@freebsd.org>
-rw-r--r-- | sys/sys/mbuf.h | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index 475b997..70fc882 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -257,13 +257,34 @@ union mcluster { } \ } +#define MCLFREE1(p) \ + do { \ + if (--mclrefcnt[mtocl(p)] == 0) { \ + ((union mcluster *)(p))->mcl_next = mclfree; \ + mclfree = (union mcluster *)(p); \ + mbstat.m_clfree++; \ + } \ + } while (0) + #define MCLFREE(p) \ - MBUFLOCK ( \ - if (--mclrefcnt[mtocl(p)] == 0) { \ - ((union mcluster *)(p))->mcl_next = mclfree; \ - mclfree = (union mcluster *)(p); \ - mbstat.m_clfree++; \ - } \ + MBUFLOCK( \ + MCLFREE1(p); \ + ) + +#define MEXTFREE1(m) \ + do { \ + if ((m)->m_ext.ext_free) \ + (*((m)->m_ext.ext_free))((m)->m_ext.ext_buf, \ + (m)->m_ext.ext_size); \ + else { \ + char *p = (m)->m_ext.ext_buf; \ + MCLFREE1(p); \ + } \ + } while (0) + +#define MEXTFREE(m) \ + MBUFLOCK( \ + MCLEXTFREE1(m); \ ) /* @@ -275,17 +296,7 @@ union mcluster { MBUFLOCK( \ mbstat.m_mtypes[(m)->m_type]--; \ if ((m)->m_flags & M_EXT) { \ - if ((m)->m_ext.ext_free) \ - (*((m)->m_ext.ext_free))((m)->m_ext.ext_buf, \ - (m)->m_ext.ext_size); \ - else { \ - char *p = (m)->m_ext.ext_buf; \ - if (--mclrefcnt[mtocl(p)] == 0) { \ - ((union mcluster *)(p))->mcl_next = mclfree; \ - mclfree = (union mcluster *)(p); \ - mbstat.m_clfree++; \ - } \ - } \ + MEXTFREE1(m); \ } \ (n) = (m)->m_next; \ (m)->m_type = MT_FREE; \ |