MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / pbuf_alloc_reference

Function pbuf_alloc_reference

components/net/lwip/lwip-2.1.2/src/core/pbuf.c:326–341  ·  view source on GitHub ↗

* @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

Source from the content-addressed store, hash-verified

324 * @return the allocated pbuf.
325 */
326struct pbuf *
327pbuf_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

Callers 1

pbuf_allocFunction · 0.85

Calls 1

pbuf_init_alloced_pbufFunction · 0.85

Tested by

no test coverage detected