Deleted Added
full compact
uipc_mbuf.c (72356) uipc_mbuf.c (72473)
1/*
2 * Copyright (c) 1982, 1986, 1988, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94
1/*
2 * Copyright (c) 1982, 1986, 1988, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94
34 * $FreeBSD: head/sys/kern/uipc_mbuf.c 72356 2001-02-11 05:02:06Z bmilekic $
34 * $FreeBSD: head/sys/kern/uipc_mbuf.c 72473 2001-02-14 05:13:04Z bmilekic $
35 */
36
37#include "opt_param.h"
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/malloc.h>
41#include <sys/mbuf.h>
42#include <sys/mutex.h>

--- 415 unchanged lines hidden (view full) ---

458 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
459 if (pr->pr_drain)
460 (*pr->pr_drain)();
461 mbstat.m_drain++;
462}
463
464/*
465 * Space allocation routines.
35 */
36
37#include "opt_param.h"
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/malloc.h>
41#include <sys/mbuf.h>
42#include <sys/mutex.h>

--- 415 unchanged lines hidden (view full) ---

458 for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
459 if (pr->pr_drain)
460 (*pr->pr_drain)();
461 mbstat.m_drain++;
462}
463
464/*
465 * Space allocation routines.
466 * These are also available as macros
466 * Some of these are also available as macros
467 * for critical paths.
468 */
469struct mbuf *
470m_get(int how, int type)
471{
472 struct mbuf *m;
473
474 MGET(m, how, type);

--- 25 unchanged lines hidden (view full) ---

500m_free(struct mbuf *m)
501{
502 struct mbuf *n;
503
504 MFREE(m, n);
505 return (n);
506}
507
467 * for critical paths.
468 */
469struct mbuf *
470m_get(int how, int type)
471{
472 struct mbuf *m;
473
474 MGET(m, how, type);

--- 25 unchanged lines hidden (view full) ---

500m_free(struct mbuf *m)
501{
502 struct mbuf *n;
503
504 MFREE(m, n);
505 return (n);
506}
507
508/*
509 * struct mbuf *
510 * m_getm(m, len, how, type)
511 *
512 * This will allocate len-worth of mbufs and/or mbuf clusters (whatever fits
513 * best) and return a pointer to the top of the allocated chain. If m is
514 * non-null, then we assume that it is a single mbuf or an mbuf chain to
515 * which we want len bytes worth of mbufs and/or clusters attached, and so
516 * if we succeed in allocating it, we will just return a pointer to m.
517 *
518 * If we happen to fail at any point during the allocation, we will free
519 * up everything we have already allocated and return NULL.
520 *
521 */
522struct mbuf *
523m_getm(struct mbuf *m, int len, int how, int type)
524{
525 struct mbuf *top, *tail, *mp, *mtail = NULL;
526
527 KASSERT(len >= 0, ("len is < 0 in m_getm"));
528
529 MGET(mp, type, how);
530 if (mp == NULL)
531 return (NULL);
532 else if (len > MINCLSIZE) {
533 MCLGET(mp, how);
534 if ((mp->m_flags & M_EXT) == 0) {
535 m_free(mp);
536 return (NULL);
537 }
538 }
539 mp->m_len = 0;
540 len -= M_TRAILINGSPACE(mp);
541
542 if (m != NULL)
543 for (mtail = m; mtail->m_next != NULL; mtail = mtail->m_next);
544 else
545 m = mp;
546
547 top = tail = mp;
548 while (len > 0) {
549 MGET(mp, type, how);
550 if (mp == NULL)
551 goto failed;
552
553 tail->m_next = mp;
554 tail = mp;
555 if (len > MINCLSIZE) {
556 MCLGET(mp, how);
557 if ((mp->m_flags & M_EXT) == 0)
558 goto failed;
559 }
560
561 mp->m_len = 0;
562 len -= M_TRAILINGSPACE(mp);
563 }
564
565 if (mtail != NULL)
566 mtail->m_next = top;
567 return (m);
568
569failed:
570 m_freem(top);
571 return (NULL);
572}
573
508void
509m_freem(struct mbuf *m)
510{
511 struct mbuf *n;
512
513 if (m == NULL)
514 return;
515 do {

--- 627 unchanged lines hidden ---
574void
575m_freem(struct mbuf *m)
576{
577 struct mbuf *n;
578
579 if (m == NULL)
580 return;
581 do {

--- 627 unchanged lines hidden ---