pbuf: Fix allocate zero length pbuf

Current code fails to allocate zero length pbuf (e.g. for PBUF_RAW PBUF_POOL),
fix it.

Fixes: eb269e61b5 ("First step to clean up pbuf implementation: add pbuf_alloc_reference() to allocate pbufs referencing external payload; move member initialization to common function; simplify PBUF_POOL chain allocator")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
This commit is contained in:
Axel Lin 2017-04-27 00:10:52 +08:00 committed by goldsimon
parent fc7a68b5af
commit 4c9b316e6b

View File

@ -305,7 +305,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
p = NULL;
last = NULL;
rem_len = length;
while (rem_len > 0) {
do {
q = (struct pbuf *)memp_malloc(MEMP_PBUF_POOL);
if (q == NULL) {
PBUF_POOL_IS_EMPTY();
@ -332,7 +332,7 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
last = q;
rem_len -= q->len;
offset = 0;
}
} while (rem_len > 0);
break;
}
case PBUF_RAM: