Teach m_copyback() to use trailing space of the last mbuf in chain.

This commit is contained in:
Alexander Motin 2009-01-18 20:19:55 +00:00
parent e4651e0595
commit 129c5c814d
1 changed files with 4 additions and 0 deletions

View File

@ -1271,6 +1271,10 @@ m_copyback(struct mbuf *m0, int off, int len, c_caddr_t cp)
m = m->m_next;
}
while (len > 0) {
if (m->m_next == NULL && (len > m->m_len - off)) {
m->m_len += min(len - (m->m_len - off),
M_TRAILINGSPACE(m));
}
mlen = min (m->m_len - off, len);
bcopy(cp, off + mtod(m, caddr_t), (u_int)mlen);
cp += mlen;