/* Allocates a new pbuf of same length (via  */
struct pbuf* pbuf_clone(pbuf_layer layer, pbuf_type type, struct pbuf *p)
/* Allocates a new pbuf of same length (via  */
struct pbuf* pbuf_clone(pbuf_layer layer, pbuf_type type, struct pbuf *p)
{
  struct pbuf *q;
  err_t err;
  q = pbuf_alloc(layer, p->tot_len, type);
  if (q == NULL) {
    return NULL;
  }
  err = pbuf_copy(q, p);
  LWIP_UNUSED_ARG(err);
  LWIP_ASSERT("pbuf_copy failed", err == ERR_OK);
  return q;
}