* @ingroup pbuf * Allocates a new pbuf of same length (via pbuf_alloc()) and copies the source * pbuf into this new pbuf (using pbuf_copy()). * * @param layer pbuf_layer of the new pbuf * @param type this parameter decides how and where the pbuf should be allocated * (@see pbuf_alloc()) * @param p the source pbuf * * @return a new pbuf or NULL if allocation fails */
| 1303 | * @return a new pbuf or NULL if allocation fails |
| 1304 | */ |
| 1305 | struct pbuf * |
| 1306 | pbuf_clone(pbuf_layer layer, pbuf_type type, struct pbuf *p) |
| 1307 | { |
| 1308 | struct pbuf *q; |
| 1309 | err_t err; |
| 1310 | q = pbuf_alloc(layer, p->tot_len, type); |
| 1311 | if (q == NULL) { |
| 1312 | return NULL; |
| 1313 | } |
| 1314 | err = pbuf_copy(q, p); |
| 1315 | LWIP_UNUSED_ARG(err); /* in case of LWIP_NOASSERT */ |
| 1316 | LWIP_ASSERT("pbuf_copy failed", err == ERR_OK); |
| 1317 | return q; |
| 1318 | } |
| 1319 | |
| 1320 | #if LWIP_CHECKSUM_ON_COPY |
| 1321 | /** |
no test coverage detected