mbuf.c (55146) | mbuf.c (55353) |
---|---|
1/* 2 * PPP Memory handling module 3 * 4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 5 * 6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the Internet Initiative Japan, Inc. The name of the 14 * IIJ may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * | 1/* 2 * PPP Memory handling module 3 * 4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 5 * 6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the Internet Initiative Japan, Inc. The name of the 14 * IIJ may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * |
20 * $FreeBSD: head/usr.sbin/ppp/mbuf.c 55146 1999-12-27 11:54:57Z brian $ | 20 * $FreeBSD: head/usr.sbin/ppp/mbuf.c 55353 2000-01-03 20:09:23Z brian $ |
21 * 22 */ 23#include <sys/types.h> 24 25#include <stdio.h> 26#include <stdlib.h> 27#include <string.h> 28#include <sysexits.h> --- 200 unchanged lines hidden (view full) --- 229 memcpy(bp + 1, (const char *)ptr + len, bp->m_offset); 230 bp->m_len += bp->m_offset; 231 bp->m_offset = 0; 232 } 233 234 head = m_get(len + extra, bp ? bp->m_type : MB_UNKNOWN); 235 head->m_offset = extra; 236 head->m_len -= extra; | 21 * 22 */ 23#include <sys/types.h> 24 25#include <stdio.h> 26#include <stdlib.h> 27#include <string.h> 28#include <sysexits.h> --- 200 unchanged lines hidden (view full) --- 229 memcpy(bp + 1, (const char *)ptr + len, bp->m_offset); 230 bp->m_len += bp->m_offset; 231 bp->m_offset = 0; 232 } 233 234 head = m_get(len + extra, bp ? bp->m_type : MB_UNKNOWN); 235 head->m_offset = extra; 236 head->m_len -= extra; |
237 memcpy(MBUF_CTOP(head), ptr, len); | 237 if (ptr) 238 memcpy(MBUF_CTOP(head), ptr, len); |
238 head->m_next = bp; 239 240 return head; 241} 242 243struct mbuf * 244m_adj(struct mbuf *bp, ssize_t n) 245{ --- 147 unchanged lines hidden (view full) --- 393 if (type != bp->m_type) { 394 MemMap[bp->m_type].fragments--; 395 MemMap[bp->m_type].octets -= bp->m_size; 396 bp->m_type = type; 397 MemMap[type].fragments++; 398 MemMap[type].octets += bp->m_size; 399 } 400} | 239 head->m_next = bp; 240 241 return head; 242} 243 244struct mbuf * 245m_adj(struct mbuf *bp, ssize_t n) 246{ --- 147 unchanged lines hidden (view full) --- 394 if (type != bp->m_type) { 395 MemMap[bp->m_type].fragments--; 396 MemMap[bp->m_type].octets -= bp->m_size; 397 bp->m_type = type; 398 MemMap[type].fragments++; 399 MemMap[type].octets += bp->m_size; 400 } 401} |
402 403struct mbuf * 404m_append(struct mbuf *m, const void *v, size_t sz) 405{ 406 if (m) { 407 while (m->m_next) 408 m = m->m_next; 409 if (m->m_size - m->m_len > sz) 410 m->m_len += sz; 411 else 412 m->m_next = m_prepend(NULL, v, sz, 0); 413 } else 414 m = m_prepend(NULL, v, sz, 0); 415 416 return m; 417} |
|