* @ingroup pbuf * Allocates a pbuf for referenced data. * Referenced data can be volatile (PBUF_REF) or long-lived (PBUF_ROM). * * The actual memory allocated for the pbuf is determined by the * layer at which the pbuf is allocated and the requested size * (from the size parameter). * * @param payload referenced payload * @param length size of the pbuf's payload * @param type this parame
| 324 | * @return the allocated pbuf. |
| 325 | */ |
| 326 | struct pbuf * |
| 327 | pbuf_alloc_reference(void *payload, u16_t length, pbuf_type type) |
| 328 | { |
| 329 | struct pbuf *p; |
| 330 | LWIP_ASSERT("invalid pbuf_type", (type == PBUF_REF) || (type == PBUF_ROM)); |
| 331 | /* only allocate memory for the pbuf structure */ |
| 332 | p = (struct pbuf *)memp_malloc(MEMP_PBUF); |
| 333 | if (p == NULL) { |
| 334 | LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_LEVEL_SERIOUS, |
| 335 | ("pbuf_alloc_reference: Could not allocate MEMP_PBUF for PBUF_%s.\n", |
| 336 | (type == PBUF_ROM) ? "ROM" : "REF")); |
| 337 | return NULL; |
| 338 | } |
| 339 | pbuf_init_alloced_pbuf(p, payload, length, length, type, 0); |
| 340 | return p; |
| 341 | } |
| 342 | |
| 343 | |
| 344 | #if LWIP_SUPPORT_CUSTOM_PBUF |
no test coverage detected