Revision 5fafdf24 slirp/mbuf.c

b/slirp/mbuf.c
40 40
	 * Find a nice value for msize
41 41
	 * XXX if_maxlinkhdr already in mtu
42 42
	 */
43
	msize = (if_mtu>if_mru?if_mtu:if_mru) + 
43
	msize = (if_mtu>if_mru?if_mtu:if_mru) +
44 44
			if_maxlinkhdr + sizeof(struct m_hdr ) + 6;
45 45
}
46 46

  
47 47
/*
48 48
 * Get an mbuf from the free list, if there are none
49 49
 * malloc one
50
 * 
50
 *
51 51
 * Because fragmentation can occur if we alloc new mbufs and
52 52
 * free old mbufs, we mark all mbufs above mbuf_thresh as M_DOFREE,
53 53
 * which tells m_free to actually free() it
......
57 57
{
58 58
	register struct mbuf *m;
59 59
	int flags = 0;
60
	
60

  
61 61
	DEBUG_CALL("m_get");
62
	
62

  
63 63
	if (m_freelist.m_next == &m_freelist) {
64 64
		m = (struct mbuf *)malloc(msize);
65 65
		if (m == NULL) goto end_error;
......
72 72
		m = m_freelist.m_next;
73 73
		remque(m);
74 74
	}
75
	
75

  
76 76
	/* Insert it in the used list */
77 77
	insque(m,&m_usedlist);
78 78
	m->m_flags = (flags | M_USEDLIST);
79
	
79

  
80 80
	/* Initialise it */
81 81
	m->m_size = msize - sizeof(struct m_hdr);
82 82
	m->m_data = m->m_dat;
......
92 92
m_free(m)
93 93
	struct mbuf *m;
94 94
{
95
	
95

  
96 96
  DEBUG_CALL("m_free");
97 97
  DEBUG_ARG("m = %lx", (long )m);
98
	
98

  
99 99
  if(m) {
100 100
	/* Remove from m_usedlist */
101 101
	if (m->m_flags & M_USEDLIST)
102 102
	   remque(m);
103
	
103

  
104 104
	/* If it's M_EXT, free() it */
105 105
	if (m->m_flags & M_EXT)
106 106
	   free(m->m_ext);
......
132 132
	 */
133 133
	if (M_FREEROOM(m) < n->m_len)
134 134
		m_inc(m,m->m_size+MINCSIZE);
135
	
135

  
136 136
	memcpy(m->m_data+m->m_len, n->m_data, n->m_len);
137 137
	m->m_len += n->m_len;
138 138

  
......
156 156
	  m->m_ext = (char *)realloc(m->m_ext,size);
157 157
/*		if (m->m_ext == NULL)
158 158
 *			return (struct mbuf *)NULL;
159
 */		
159
 */	
160 160
	  m->m_data = m->m_ext + datasize;
161 161
        } else {
162 162
	  char *dat;
......
166 166
 *			return (struct mbuf *)NULL;
167 167
 */
168 168
	  memcpy(dat, m->m_dat, m->m_size);
169
	  
169
	 
170 170
	  m->m_ext = dat;
171 171
	  m->m_data = m->m_ext + datasize;
172 172
	  m->m_flags |= M_EXT;
173 173
        }
174
 
174

  
175 175
        m->m_size = size;
176 176

  
177 177
}
......
224 224
	void *dat;
225 225
{
226 226
	struct mbuf *m;
227
	
227

  
228 228
	DEBUG_CALL("dtom");
229 229
	DEBUG_ARG("dat = %lx", (long )dat);
230 230

  
......
238 238
	      return m;
239 239
	  }
240 240
	}
241
	
241

  
242 242
	DEBUG_ERROR((dfd, "dtom failed"));
243
	
243

  
244 244
	return (struct mbuf *)0;
245 245
}
246 246

  

Also available in: Unified diff