251 |
p->len = length > PBUF_POOL_BUFSIZE - offset? PBUF_POOL_BUFSIZE - offset: length; |
p->len = length > PBUF_POOL_BUFSIZE - offset? PBUF_POOL_BUFSIZE - offset: length; |
252 |
/* set pbuf type */ |
/* set pbuf type */ |
253 |
p->flags = PBUF_FLAG_POOL; |
p->flags = PBUF_FLAG_POOL; |
254 |
|
/* set reference count (needed here in case we fail) */ |
255 |
|
p->ref = 1; |
256 |
|
|
257 |
/* now allocate the tail of the pbuf chain */ |
/* now allocate the tail of the pbuf chain */ |
258 |
|
|
268 |
#ifdef PBUF_STATS |
#ifdef PBUF_STATS |
269 |
++lwip_stats.pbuf.err; |
++lwip_stats.pbuf.err; |
270 |
#endif /* PBUF_STATS */ |
#endif /* PBUF_STATS */ |
271 |
/* bail out unsuccesfully */ |
/* free chain so far allocated */ |
272 |
pbuf_free(p); |
pbuf_free(p); |
273 |
|
/* bail out unsuccesfully */ |
274 |
return NULL; |
return NULL; |
275 |
} |
} |
276 |
/*q->next = NULL;*/ |
q->next = NULL; |
277 |
/* make previous pbuf point to this pbuf */ |
/* make previous pbuf point to this pbuf */ |
278 |
r->next = q; |
r->next = q; |
279 |
/* set total length of this pbuf and next in chain */ |
/* set total length of this pbuf and next in chain */ |
329 |
LWIP_ASSERT("pbuf_alloc: erroneous flag", 0); |
LWIP_ASSERT("pbuf_alloc: erroneous flag", 0); |
330 |
return NULL; |
return NULL; |
331 |
} |
} |
332 |
|
/* set reference count */ |
333 |
p->ref = 1; |
p->ref = 1; |
334 |
return p; |
return p; |
335 |
} |
} |