to leave offset pointing in current mbuf [cluster], don't go an extra turn
around the loop with a zero count
SCCS-vsn: sys/kern/uipc_mbuf.c 6.6
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*
- * @(#)uipc_mbuf.c 6.5 (Berkeley) %G%
+ * @(#)uipc_mbuf.c 6.6 (Berkeley) %G%
*/
#include "../machine/pte.h"
*/
#include "../machine/pte.h"
+/*
+ * Rearange an mbuf chain so that len bytes are contiguous
+ * and in the data area of an mbuf (so that mtod and dtom
+ * will work for a structure of size len).
+ * Returns the resulting mbuf chain on success,
+ * frees it and returns null on failure.
+ */
struct mbuf *
m_pullup(m0, len)
struct mbuf *m0;
struct mbuf *
m_pullup(m0, len)
struct mbuf *m0;
goto bad;
m->m_len = 0;
do {
goto bad;
m->m_len = 0;
do {
- count = MIN(MLEN - m->m_len, len);
- if (count > n->m_len)
- count = n->m_len;
+ count = MIN(n->m_len, len);
bcopy(mtod(n, caddr_t), mtod(m, caddr_t)+m->m_len,
(unsigned)count);
len -= count;
m->m_len += count;
bcopy(mtod(n, caddr_t), mtod(m, caddr_t)+m->m_len,
(unsigned)count);
len -= count;
m->m_len += count;
n->m_len -= count;
if (n->m_len)
n->m_len -= count;
if (n->m_len)
- break;
- n = m_free(n);
- } while (n);
+ n->m_off += count;
+ else
+ n = m_free(n);
+ } while (len && n);
if (len) {
(void) m_free(m);
goto bad;
if (len) {
(void) m_free(m);
goto bad;