本文整理汇总了C++中M_TRAILINGSPACE函数的典型用法代码示例。如果您正苦于以下问题:C++ M_TRAILINGSPACE函数的具体用法?C++ M_TRAILINGSPACE怎么用?C++ M_TRAILINGSPACE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了M_TRAILINGSPACE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: smb_rq_dmem
int
smb_rq_dmem(struct mbdata *mbp, const char *src, size_t size)
{
struct mbuf *m;
char * dst;
int cplen, error;
if (size == 0)
return 0;
m = mbp->mb_cur;
if ((error = m_getm(m, size, &m)) != 0)
return error;
while (size > 0) {
cplen = M_TRAILINGSPACE(m);
if (cplen == 0) {
m = m->m_next;
continue;
}
if (cplen > (int)size)
cplen = size;
dst = mtod(m, char *) + m->m_len;
nls_mem_toext(dst, src, cplen);
size -= cplen;
src += cplen;
m->m_len += cplen;
mbp->mb_count += cplen;
}
mbp->mb_pos = mtod(m, char *) + m->m_len;
mbp->mb_cur = m;
return 0;
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:31,代码来源:rq.c
示例2: sbcreatecontrol
/*
* Create a "control" mbuf containing the specified data with the specified
* type for presentation on a socket buffer.
*/
struct mbuf *
sbcreatecontrol(caddr_t p, int size, int type, int level)
{
struct cmsghdr *cp;
struct mbuf *m;
if (CMSG_SPACE((u_int)size) > MCLBYTES)
return ((struct mbuf *) NULL);
if (CMSG_SPACE((u_int)size) > MLEN)
m = m_getcl(M_NOWAIT, MT_CONTROL, 0);
else
m = m_get(M_NOWAIT, MT_CONTROL);
if (m == NULL)
return ((struct mbuf *) NULL);
cp = mtod(m, struct cmsghdr *);
m->m_len = 0;
KASSERT(CMSG_SPACE((u_int)size) <= M_TRAILINGSPACE(m),
("sbcreatecontrol: short mbuf"));
/*
* Don't leave the padding between the msg header and the
* cmsg data and the padding after the cmsg data un-initialized.
*/
bzero(cp, CMSG_SPACE((u_int)size));
if (p != NULL)
(void)memcpy(CMSG_DATA(cp), p, size);
m->m_len = CMSG_SPACE(size);
cp->cmsg_len = CMSG_LEN(size);
cp->cmsg_level = level;
cp->cmsg_type = type;
return (m);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:35,代码来源:uipc_sockbuf.c
示例3: mb_put_mem
int
mb_put_mem(struct mbdata *mbp, const char *source, size_t size)
{
struct mbuf *m;
char * dst;
size_t cplen;
int error;
if (size == 0)
return 0;
m = mbp->mb_cur;
if ((error = m_getm(m, size, &m)) != 0)
return error;
while (size > 0) {
cplen = M_TRAILINGSPACE(m);
if (cplen == 0) {
m = m->m_next;
continue;
}
if (cplen > size)
cplen = size;
dst = mtod(m, char *) + m->m_len;
if (source) {
bcopy(source, dst, cplen);
source += cplen;
} else
bzero(dst, cplen);
size -= cplen;
m->m_len += cplen;
mbp->mb_count += cplen;
}
mbp->mb_pos = mtod(m, char *) + m->m_len;
mbp->mb_cur = m;
return 0;
}
开发者ID:carriercomm,项目名称:fs-utils,代码行数:35,代码来源:mbuf.c
示例4: mb_initm
void
mb_initm(struct mbchain *mbp, struct mbuf *m)
{
bzero(mbp, sizeof(*mbp));
mbp->mb_top = mbp->mb_cur = m;
mbp->mb_mleft = M_TRAILINGSPACE(m);
}
开发者ID:jaredmcneill,项目名称:freebsd,代码行数:7,代码来源:subr_mchain.c
示例5: sbcompress
/*
* Append the data in mbuf chain (m) into the socket buffer sb following mbuf
* (n). If (n) is NULL, the buffer is presumed empty.
*
* When the data is compressed, mbufs in the chain may be handled in one of
* three ways:
*
* (1) The mbuf may simply be dropped, if it contributes nothing (no data, no
* record boundary, and no change in data type).
*
* (2) The mbuf may be coalesced -- i.e., data in the mbuf may be copied into
* an mbuf already in the socket buffer. This can occur if an
* appropriate mbuf exists, there is room, and no merging of data types
* will occur.
*
* (3) The mbuf may be appended to the end of the existing mbuf chain.
*
* If any of the new mbufs is marked as M_EOR, mark the last mbuf appended as
* end-of-record.
*/
void
sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n)
{
int eor = 0;
struct mbuf *o;
SOCKBUF_LOCK_ASSERT(sb);
while (m) {
eor |= m->m_flags & M_EOR;
if (m->m_len == 0 &&
(eor == 0 ||
(((o = m->m_next) || (o = n)) &&
o->m_type == m->m_type))) {
if (sb->sb_lastrecord == m)
sb->sb_lastrecord = m->m_next;
m = m_free(m);
continue;
}
if (n && (n->m_flags & M_EOR) == 0 &&
M_WRITABLE(n) &&
((sb->sb_flags & SB_NOCOALESCE) == 0) &&
m->m_len <= M_TRAILINGSPACE(n) &&
n->m_type == m->m_type) {
if (n->m_flags & M_HOLE) {
n->m_len += m->m_len;
sb->sb_cc += m->m_len;
m = m_free(m);
continue;
} else if (m->m_len <= MCLBYTES / 4) { /* XXX: Don't copy too much */
bcopy(mtod(m, caddr_t),
mtod(n, caddr_t) + n->m_len,
(unsigned)m->m_len);
n->m_len += m->m_len;
sb->sb_cc += m->m_len;
if (m->m_type != MT_DATA &&
m->m_type != MT_OOBDATA)
/* XXX: Probably don't need.*/
sb->sb_ctl += m->m_len;
m = m_free(m);
continue;
}
}
if (n)
n->m_next = m;
else
sb->sb_mb = m;
sb->sb_mbtail = m;
sballoc(sb, m);
n = m;
m->m_flags &= ~M_EOR;
m = m->m_next;
n->m_next = 0;
}
if (eor) {
KASSERT(n != NULL, ("sbcompress: eor && n == NULL"));
n->m_flags |= eor;
}
SBLASTMBUFCHK(sb);
}
开发者ID:bigclouds,项目名称:libuinet,代码行数:80,代码来源:uipc_sockbuf.c
示例6: sbcreatecontrol
/*
* Create a "control" mbuf containing the specified data with the specified
* type for presentation on a socket buffer.
*/
struct mbuf *
sbcreatecontrol(caddr_t p, int size, int type, int level)
{
struct cmsghdr *cp;
struct mbuf *m;
if (CMSG_SPACE((u_int)size) > MCLBYTES)
return ((struct mbuf *) NULL);
if (CMSG_SPACE((u_int)size) > MLEN)
m = m_getcl(M_DONTWAIT, MT_CONTROL, 0);
else
m = m_get(M_DONTWAIT, MT_CONTROL);
if (m == NULL)
return ((struct mbuf *) NULL);
cp = mtod(m, struct cmsghdr *);
m->m_len = 0;
KASSERT(CMSG_SPACE((u_int)size) <= M_TRAILINGSPACE(m),
("sbcreatecontrol: short mbuf"));
if (p != NULL)
(void)memcpy(CMSG_DATA(cp), p, size);
m->m_len = CMSG_SPACE(size);
cp->cmsg_len = CMSG_LEN(size);
cp->cmsg_level = level;
cp->cmsg_type = type;
return (m);
}
开发者ID:Pieter-was,项目名称:osv,代码行数:30,代码来源:uipc_sockbuf.c
示例7: m_collapse
/*
* Defragment an mbuf chain, returning at most maxfrags separate
* mbufs+clusters. If this is not possible NULL is returned and
* the original mbuf chain is left in it's present (potentially
* modified) state. We use two techniques: collapsing consecutive
* mbufs and replacing consecutive mbufs by a cluster.
*
* NB: this should really be named m_defrag but that name is taken
*/
struct mbuf *
m_collapse(struct mbuf *m0, int how, int maxfrags)
{
struct mbuf *m, *n, *n2, **prev;
u_int curfrags;
/*
* Calculate the current number of frags.
*/
curfrags = 0;
for (m = m0; m != NULL; m = m->m_next)
curfrags++;
/*
* First, try to collapse mbufs. Note that we always collapse
* towards the front so we don't need to deal with moving the
* pkthdr. This may be suboptimal if the first mbuf has much
* less data than the following.
*/
m = m0;
again:
for (;;) {
n = m->m_next;
if (n == NULL)
break;
if (M_WRITABLE(m) &&
n->m_len < M_TRAILINGSPACE(m)) {
bcopy(mtod(n, void *), mtod(m, char *) + m->m_len,
n->m_len);
m->m_len += n->m_len;
m->m_next = n->m_next;
m_free(n);
if (--curfrags <= maxfrags)
return m0;
} else
开发者ID:vocho,项目名称:freebsd-base-graphics,代码行数:43,代码来源:uipc_mbuf.c
示例8: m_megapullup
m_megapullup(PNATState pData, struct mbuf *m, int len)
#endif
{
struct mbuf *mcl;
if (len > m->m_pkthdr.len)
goto bad;
/* Do not reallocate packet if it is sequentional,
* writable and has some extra space for expansion.
* XXX: Constant 100bytes is completely empirical. */
#define RESERVE 100
if (m->m_next == NULL && M_WRITABLE(m) && M_TRAILINGSPACE(m) >= RESERVE)
return (m);
if (len <= MCLBYTES - RESERVE) {
#ifndef VBOX
mcl = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
#else
mcl = m_getcl(pData, M_DONTWAIT, MT_DATA, M_PKTHDR);
#endif
} else if (len < MJUM16BYTES) {
int size;
if (len <= MJUMPAGESIZE - RESERVE) {
size = MJUMPAGESIZE;
} else if (len <= MJUM9BYTES - RESERVE) {
size = MJUM9BYTES;
} else {
size = MJUM16BYTES;
};
#ifndef VBOX
mcl = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, size);
#else
mcl = m_getjcl(pData, M_DONTWAIT, MT_DATA, M_PKTHDR, size);
#endif
} else {
goto bad;
}
if (mcl == NULL)
goto bad;
m_move_pkthdr(mcl, m);
m_copydata(m, 0, len, mtod(mcl, caddr_t));
mcl->m_len = mcl->m_pkthdr.len = len;
#ifndef VBOX
m_freem(m);
#else
m_freem(pData, m);
#endif
return (mcl);
bad:
#ifndef VBOX
m_freem(m);
#else
m_freem(pData, m);
#endif
return (NULL);
}
开发者ID:MadHacker217,项目名称:VirtualBox-OSE,代码行数:59,代码来源:alias.c
示例9: mb_put_mem
int
mb_put_mem(struct mbchain *mbp, c_caddr_t source, int size, int type)
{
struct mbuf *m;
caddr_t dst;
c_caddr_t src;
int cplen, error, mleft, count;
size_t srclen, dstlen;
m = mbp->mb_cur;
mleft = mbp->mb_mleft;
while (size > 0) {
if (mleft == 0) {
if (m->m_next == NULL)
m = m_getm(m, size, M_WAIT, MT_DATA);
else
m = m->m_next;
mleft = M_TRAILINGSPACE(m);
continue;
}
cplen = mleft > size ? size : mleft;
srclen = dstlen = cplen;
dst = mtod(m, caddr_t) + m->m_len;
switch (type) {
case MB_MCUSTOM:
srclen = size;
dstlen = mleft;
error = mbp->mb_copy(mbp, source, dst, &srclen, &dstlen);
if (error)
return error;
break;
case MB_MINLINE:
for (src = source, count = cplen; count; count--)
*dst++ = *src++;
break;
case MB_MSYSTEM:
bcopy(source, dst, cplen);
break;
case MB_MUSER:
error = copyin(source, dst, cplen);
if (error)
return error;
break;
case MB_MZERO:
bzero(dst, cplen);
break;
}
size -= srclen;
source += srclen;
m->m_len += dstlen;
mleft -= dstlen;
mbp->mb_count += dstlen;
}
mbp->mb_cur = m;
mbp->mb_mleft = mleft;
return 0;
}
开发者ID:BillTheBest,项目名称:libuinet,代码行数:58,代码来源:subr_mchain.c
示例10: mb_put_mbuf
int
mb_put_mbuf(struct mbchain *mbp, struct mbuf *m)
{
mbp->mb_cur->m_next = m;
while (m) {
mbp->mb_count += m->m_len;
if (m->m_next == NULL)
break;
m = m->m_next;
}
mbp->mb_mleft = M_TRAILINGSPACE(m);
mbp->mb_cur = m;
return 0;
}
开发者ID:BillTheBest,项目名称:libuinet,代码行数:14,代码来源:subr_mchain.c
示例11: sbcompress
/*
* Compress mbuf chain m into the socket
* buffer sb following mbuf n. If n
* is null, the buffer is presumed empty.
*/
void
sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n)
{
int eor = 0;
struct mbuf *o;
while (m) {
eor |= m->m_flags & M_EOR;
if (m->m_len == 0 &&
(eor == 0 ||
(((o = m->m_next) || (o = n)) &&
o->m_type == m->m_type))) {
if (sb->sb_lastrecord == m)
sb->sb_lastrecord = m->m_next;
m = m_free(m);
continue;
}
if (n && (n->m_flags & M_EOR) == 0 &&
/* M_TRAILINGSPACE() checks buffer writeability */
m->m_len <= MCLBYTES / 4 && /* XXX Don't copy too much */
m->m_len <= M_TRAILINGSPACE(n) &&
n->m_type == m->m_type) {
memcpy(mtod(n, caddr_t) + n->m_len, mtod(m, caddr_t),
m->m_len);
n->m_len += m->m_len;
sb->sb_cc += m->m_len;
if (m->m_type != MT_CONTROL && m->m_type != MT_SONAME)
sb->sb_datacc += m->m_len;
m = m_free(m);
continue;
}
if (n)
n->m_next = m;
else
sb->sb_mb = m;
sb->sb_mbtail = m;
sballoc(sb, m);
n = m;
m->m_flags &= ~M_EOR;
m = m->m_next;
n->m_next = NULL;
}
if (eor) {
if (n)
n->m_flags |= eor;
else
printf("semi-panic: sbcompress");
}
SBLASTMBUFCHK(sb, __func__);
}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:55,代码来源:uipc_socket2.c
示例12: pppwrite
/*
* Line specific (tty) write routine.
*/
int
pppwrite(struct rtems_termios_tty *tty, rtems_libio_rw_args_t *rw_args)
{
struct sockaddr dst;
int n;
int len;
int maximum = rw_args->count;
char *out_buffer = rw_args->buffer;
register struct ppp_softc *sc = (struct ppp_softc *)tty->t_sc;
struct mbuf *m;
struct mbuf *m0;
struct mbuf **mp;
rtems_bsdnet_semaphore_obtain();
for (mp = &m0; maximum; mp = &m->m_next) {
MGET(m, M_WAIT, MT_DATA);
if ((*mp = m) == NULL) {
m_freem(m0);
return (ENOBUFS);
}
m->m_len = 0;
if (maximum >= MCLBYTES / 2) {
MCLGET(m, M_DONTWAIT);
}
len = M_TRAILINGSPACE(m);
if (len > maximum) {
memcpy(mtod(m, u_char *),out_buffer,maximum);
m->m_len = maximum;
maximum = 0;
}
else {
memcpy(mtod(m, u_char *),out_buffer,len);
m->m_len = len;
maximum -= len;
out_buffer += len;
}
}
dst.sa_family = AF_UNSPEC;
bcopy(mtod(m0, u_char *), dst.sa_data, PPP_HDRLEN);
m0->m_data += PPP_HDRLEN;
m0->m_len -= PPP_HDRLEN;
n = pppoutput(&sc->sc_if, m0, &dst, (struct rtentry *)0);
rtems_bsdnet_semaphore_release();
return ( n );
}
开发者ID:FullMentalPanic,项目名称:RTEMS_NEW_TOOL_CHAIN,代码行数:51,代码来源:ppp_tty.c
示例13: m_copyback
/*
* Copy data from a buffer back into the indicated mbuf chain,
* starting "off" bytes from the beginning, extending the mbuf
* chain if necessary.
*/
void
m_copyback(struct mbuf *m0, int off, int len, c_caddr_t cp)
{
int mlen;
struct mbuf *m = m0, *n;
int totlen = 0;
if (m0 == NULL)
return;
while (off > (mlen = m->m_len)) {
off -= mlen;
totlen += mlen;
if (m->m_next == NULL) {
n = m_get(M_NOWAIT, m->m_type);
if (n == NULL)
goto out;
bzero(mtod(n, caddr_t), MLEN);
n->m_len = min(MLEN, len + off);
m->m_next = n;
}
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;
len -= mlen;
mlen += off;
off = 0;
totlen += mlen;
if (len == 0)
break;
if (m->m_next == NULL) {
n = m_get(M_NOWAIT, m->m_type);
if (n == NULL)
break;
n->m_len = min(MLEN, len);
m->m_next = n;
}
m = m->m_next;
}
out: if (((m = m0)->m_flags & M_PKTHDR) && (m->m_pkthdr.len < totlen))
m->m_pkthdr.len = totlen;
}
开发者ID:cleveritcz,项目名称:f-stack,代码行数:53,代码来源:uipc_mbuf.c
示例14: m_cat
/*
* Concatenate mbuf chain n to m.
* n might be copied into m (when n->m_len is small), therefore data portion of
* n could be copied into an mbuf of different mbuf type.
* Therefore both chains should be of the same type (e.g. MT_DATA).
* Any m_pkthdr is not updated.
*/
void
m_cat(struct mbuf *m, struct mbuf *n)
{
while (m->m_next)
m = m->m_next;
while (n) {
if (M_READONLY(m) || n->m_len > M_TRAILINGSPACE(m)) {
/* just join the two chains */
m->m_next = n;
return;
}
/* splat the data from one into the other */
memcpy(mtod(m, caddr_t) + m->m_len, mtod(n, caddr_t),
n->m_len);
m->m_len += n->m_len;
n = m_free(n);
}
}
开发者ID:orumin,项目名称:openbsd-efivars,代码行数:25,代码来源:uipc_mbuf.c
示例15: vte_encap
struct vte_txdesc *
vte_encap(struct vte_softc *sc, struct mbuf **m_head)
{
struct vte_txdesc *txd;
struct mbuf *m, *n;
int copy, error, padlen;
txd = &sc->vte_cdata.vte_txdesc[sc->vte_cdata.vte_tx_prod];
m = *m_head;
/*
* Controller doesn't auto-pad, so we have to make sure pad
* short frames out to the minimum frame length.
*/
if (m->m_pkthdr.len < VTE_MIN_FRAMELEN)
padlen = VTE_MIN_FRAMELEN - m->m_pkthdr.len;
else
padlen = 0;
/*
* Controller does not support multi-fragmented TX buffers.
* Controller spends most of its TX processing time in
* de-fragmenting TX buffers. Either faster CPU or more
* advanced controller DMA engine is required to speed up
* TX path processing.
* To mitigate the de-fragmenting issue, perform deep copy
* from fragmented mbuf chains to a pre-allocated mbuf
* cluster with extra cost of kernel memory. For frames
* that is composed of single TX buffer, the deep copy is
* bypassed.
*/
copy = 0;
if (m->m_next != NULL)
copy++;
if (padlen > 0 && (padlen > M_TRAILINGSPACE(m)))
copy++;
if (copy != 0) {
/* Avoid expensive m_defrag(9) and do deep copy. */
n = sc->vte_cdata.vte_txmbufs[sc->vte_cdata.vte_tx_prod];
m_copydata(m, 0, m->m_pkthdr.len, mtod(n, char *));
n->m_pkthdr.len = m->m_pkthdr.len;
n->m_len = m->m_pkthdr.len;
m = n;
txd->tx_flags |= VTE_TXMBUF;
}
开发者ID:orumin,项目名称:openbsd-efivars,代码行数:44,代码来源:if_vte.c
示例16: sbcompress
/*
* Compress mbuf chain m into the socket
* buffer sb following mbuf n. If n
* is null, the buffer is presumed empty.
*/
void
sbcompress(struct sockbuf *sb, struct mbuf *m, struct mbuf *n)
{
int eor;
struct mbuf *o;
KASSERT(solocked(sb->sb_so));
eor = 0;
while (m) {
eor |= m->m_flags & M_EOR;
if (m->m_len == 0 &&
(eor == 0 ||
(((o = m->m_next) || (o = n)) &&
o->m_type == m->m_type))) {
if (sb->sb_lastrecord == m)
sb->sb_lastrecord = m->m_next;
m = m_free(m);
continue;
}
if (n && (n->m_flags & M_EOR) == 0 &&
/* M_TRAILINGSPACE() checks buffer writeability */
m->m_len <= MCLBYTES / 4 && /* XXX Don't copy too much */
m->m_len <= M_TRAILINGSPACE(n) &&
n->m_type == m->m_type) {
memcpy(mtod(n, char *) + n->m_len, mtod(m, void *),
(unsigned)m->m_len);
n->m_len += m->m_len;
sb->sb_cc += m->m_len;
m = m_free(m);
continue;
}
if (n)
n->m_next = m;
else
sb->sb_mb = m;
sb->sb_mbtail = m;
sballoc(sb, m);
n = m;
m->m_flags &= ~M_EOR;
m = m->m_next;
n->m_next = 0;
}
开发者ID:bigclouds,项目名称:netbsd_dpdk_port,代码行数:48,代码来源:uipc_socket2.c
示例17: m_cat
/*
* Concatenate mbuf chain n to m.
* Both chains must be of the same type (e.g. MT_DATA).
* Any m_pkthdr is not updated.
*/
void
m_cat(struct mbuf *m, struct mbuf *n)
{
while (m->m_next)
m = m->m_next;
while (n) {
if (!M_WRITABLE(m) ||
M_TRAILINGSPACE(m) < n->m_len) {
/* just join the two chains */
m->m_next = n;
return;
}
/* splat the data from one into the other */
bcopy(mtod(n, caddr_t), mtod(m, caddr_t) + m->m_len,
(u_int)n->m_len);
m->m_len += n->m_len;
n = m_free(n);
}
}
开发者ID:cleveritcz,项目名称:f-stack,代码行数:24,代码来源:uipc_mbuf.c
示例18: mb_fixhdr
/*
int
mb_fixhdr(struct mbdata *mbp)
{
struct mbuf *m = mbp->mb_top;
int len = 0;
while (m) {
len += m->m_len;
m = m->m_next;
}
mbp->mb_top->m_pkthdr.len = len;
return len;
}
*/
int
m_getm(struct mbuf *top, size_t len, struct mbuf **mpp)
{
struct mbuf *m, *mp;
int error;
for (mp = top; ; mp = mp->m_next) {
len -= M_TRAILINGSPACE(mp);
if (mp->m_next == NULL)
break;
}
if (len > 0) {
if ((error = m_get(len, &m)) != 0)
return error;
mp->m_next = m;
}
*mpp = top;
return 0;
}
开发者ID:carriercomm,项目名称:fs-utils,代码行数:35,代码来源:mbuf.c
示例19: nfsm_build_xx
void *
nfsm_build_xx(int s, struct mbuf **mb, caddr_t *bpos)
{
struct mbuf *mb2;
void *ret;
if (s > M_TRAILINGSPACE(*mb)) {
mb2 = m_get(M_WAITOK, MT_DATA);
if (s > MLEN)
panic("build > MLEN");
(*mb)->m_next = mb2;
*mb = mb2;
(*mb)->m_len = 0;
*bpos = mtod(*mb, caddr_t);
}
ret = *bpos;
(*mb)->m_len += s;
*bpos += s;
return (ret);
}
开发者ID:coyizumi,项目名称:cs111,代码行数:20,代码来源:nfs_common.c
示例20: mb_fit
/*
* Check if object of size 'size' fit to the current position and
* allocate new mbuf if not. Advance pointers and increase length of mbuf(s).
* Return pointer to the object placeholder or NULL if any error occured.
*/
int
mb_fit(struct mbdata *mbp, size_t size, void **pp)
{
struct mbuf *m, *mn;
int error;
m = mbp->mb_cur;
if (M_TRAILINGSPACE(m) < (int)size) {
if ((error = m_get(size, &mn)) != 0)
return error;
mbp->mb_pos = mtod(mn, char *);
mbp->mb_cur = m->m_next = mn;
m = mn;
}
m->m_len += size;
*pp = mbp->mb_pos;
mbp->mb_pos += size;
mbp->mb_count += size;
return 0;
}
开发者ID:carriercomm,项目名称:fs-utils,代码行数:25,代码来源:mbuf.c
注:本文中的M_TRAILINGSPACE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论