Lines Matching refs:p

263   struct pbuf *p, *q, *r;  in pbuf_alloc_ext()  local
321 p = (struct pbuf *)memp_malloc(pbuf_pool_small ? MEMP_PBUF_POOL_SMALL : MEMP_PBUF_POOL); in pbuf_alloc_ext()
323 p = (struct pbuf *)memp_malloc(MEMP_PBUF_POOL); in pbuf_alloc_ext()
325 LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc: allocated pbuf %p\n", (void *)p)); in pbuf_alloc_ext()
326 if (p == NULL) { in pbuf_alloc_ext()
330 p->type = type; in pbuf_alloc_ext()
331 p->next = NULL; in pbuf_alloc_ext()
334 p->payload = LWIP_MEM_ALIGN((void *)((u8_t *)p + (SIZEOF_STRUCT_PBUF + offset))); in pbuf_alloc_ext()
336 ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0); in pbuf_alloc_ext()
338 p->tot_len = length; in pbuf_alloc_ext()
345 p->mb_flags |= PBUF_FLAG_POOL_SMALL; in pbuf_alloc_ext()
348 p->mb_flags &= ~PBUF_FLAG_POOL_SMALL; in pbuf_alloc_ext()
350 p->len = LWIP_MIN(length, pbuf_pool_bufsize_aligned - LWIP_MEM_ALIGN_SIZE(offset) - tail_space); in pbuf_alloc_ext()
352 ((u8_t*)p->payload + p->len <= in pbuf_alloc_ext()
353 (u8_t*)p + SIZEOF_STRUCT_PBUF + pbuf_pool_bufsize_aligned)); in pbuf_alloc_ext()
357 p->len = LWIP_MIN(length, PBUF_POOL_BUFSIZE_ALIGNED - LWIP_MEM_ALIGN_SIZE(offset) - tail_space); in pbuf_alloc_ext()
359 ((u8_t*)p->payload + p->len <= in pbuf_alloc_ext()
360 (u8_t*)p + SIZEOF_STRUCT_PBUF + PBUF_POOL_BUFSIZE_ALIGNED)); in pbuf_alloc_ext()
364 LWIP_ASSERT("pbuf_alloc: bad pbuf length", p->len == length); in pbuf_alloc_ext()
366 p->len = LWIP_MIN(length, PBUF_POOL_BUFSIZE_ALIGNED - LWIP_MEM_ALIGN_SIZE(offset)); in pbuf_alloc_ext()
368 ((u8_t*)p->payload + p->len <= in pbuf_alloc_ext()
369 (u8_t*)p + SIZEOF_STRUCT_PBUF + PBUF_POOL_BUFSIZE_ALIGNED)); in pbuf_alloc_ext()
374 p->ref = 1; in pbuf_alloc_ext()
379 r = p; in pbuf_alloc_ext()
381 rem_len = length - p->len; in pbuf_alloc_ext()
388 pbuf_free(p); in pbuf_alloc_ext()
406 ((u8_t*)p->payload + p->len <= in pbuf_alloc_ext()
407 (u8_t*)p + SIZEOF_STRUCT_PBUF + PBUF_POOL_BUFSIZE_ALIGNED)); in pbuf_alloc_ext()
421p = (struct pbuf*)mem_malloc(LWIP_MEM_ALIGN_SIZE(SIZEOF_STRUCT_PBUF + offset) + LWIP_MEM_ALIGN_SIZ… in pbuf_alloc_ext()
423p = (struct pbuf*)mem_malloc(LWIP_MEM_ALIGN_SIZE(SIZEOF_STRUCT_PBUF + offset) + LWIP_MEM_ALIGN_SIZ… in pbuf_alloc_ext()
425 if (p == NULL) { in pbuf_alloc_ext()
429 p->payload = LWIP_MEM_ALIGN((void *)((u8_t *)p + SIZEOF_STRUCT_PBUF + offset)); in pbuf_alloc_ext()
430 p->len = p->tot_len = length; in pbuf_alloc_ext()
431 p->next = NULL; in pbuf_alloc_ext()
432 p->type = type; in pbuf_alloc_ext()
435 ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0); in pbuf_alloc_ext()
442 p = (struct pbuf *)memp_malloc(MEMP_PBUF); in pbuf_alloc_ext()
443 if (p == NULL) { in pbuf_alloc_ext()
450 p->payload = NULL; in pbuf_alloc_ext()
451 p->len = p->tot_len = length; in pbuf_alloc_ext()
452 p->next = NULL; in pbuf_alloc_ext()
453 p->type = type; in pbuf_alloc_ext()
460 p->ref = 1; in pbuf_alloc_ext()
462 p->flags = 0; in pbuf_alloc_ext()
464 p->mb_flags = (tail_space > 0) ? PBUF_FLAG_MBUF_SPACE : 0; in pbuf_alloc_ext()
467 p->mb_flags |= PBUF_FLAG_POOL_SMALL; in pbuf_alloc_ext()
470 …IP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc(length=%"U16_F") == %p\n", length, (void *)p)); in pbuf_alloc_ext()
471 return p; in pbuf_alloc_ext()
492 pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type, struct pbuf_custom *p, in pbuf_alloced_custom() argument
529 p->pbuf.next = NULL; in pbuf_alloced_custom()
531 p->pbuf.payload = (u8_t *)payload_mem + LWIP_MEM_ALIGN_SIZE(offset); in pbuf_alloced_custom()
533 p->pbuf.payload = NULL; in pbuf_alloced_custom()
535 p->pbuf.flags = PBUF_FLAG_IS_CUSTOM; in pbuf_alloced_custom()
536 p->pbuf.len = p->pbuf.tot_len = length; in pbuf_alloced_custom()
537 p->pbuf.type = type; in pbuf_alloced_custom()
538 p->pbuf.ref = 1; in pbuf_alloced_custom()
539 return &p->pbuf; in pbuf_alloced_custom()
560 pbuf_realloc(struct pbuf *p, u16_t new_len) in pbuf_realloc() argument
566 LWIP_ASSERT("pbuf_realloc: p != NULL", p != NULL); in pbuf_realloc()
567 LWIP_ASSERT("pbuf_realloc: sane p->type", p->type == PBUF_POOL || in pbuf_realloc()
568 p->type == PBUF_ROM || in pbuf_realloc()
569 p->type == PBUF_RAM || in pbuf_realloc()
570 p->type == PBUF_REF); in pbuf_realloc()
573 if (new_len >= p->tot_len) { in pbuf_realloc()
580 grow = new_len - p->tot_len; in pbuf_realloc()
584 q = p; in pbuf_realloc()
638 pbuf_head_space(struct pbuf *p) in pbuf_head_space() argument
640 LWIP_ASSERT("p != NULL", p != NULL); in pbuf_head_space()
642 u16_t type = p->type; in pbuf_head_space()
644 return ((u8_t *)p->payload - ((u8_t *)p + SIZEOF_STRUCT_PBUF)); in pbuf_head_space()
662 pbuf_header_impl(struct pbuf *p, s16_t header_size_increment, u8_t force) in pbuf_header_impl() argument
668 LWIP_ASSERT("p != NULL", p != NULL); in pbuf_header_impl()
669 if ((header_size_increment == 0) || (p == NULL)) { in pbuf_header_impl()
676 LWIP_ERROR("increment_magnitude <= p->len", (increment_magnitude <= p->len), return 1;); in pbuf_header_impl()
684 p->type == PBUF_RAM || p->type == PBUF_POOL); in pbuf_header_impl()
687 (u8_t *)p->payload - increment_magnitude >= (u8_t *)p + SIZEOF_STRUCT_PBUF); in pbuf_header_impl()
691 type = p->type; in pbuf_header_impl()
693 payload = p->payload; in pbuf_header_impl()
698 p->payload = (u8_t *)p->payload - header_size_increment; in pbuf_header_impl()
700 if ((u8_t *)p->payload < (u8_t *)p + SIZEOF_STRUCT_PBUF) { in pbuf_header_impl()
703 (void *)p->payload, (void *)((u8_t *)p + SIZEOF_STRUCT_PBUF))); in pbuf_header_impl()
705 p->payload = payload; in pbuf_header_impl()
712 if ((header_size_increment < 0) && (increment_magnitude <= p->len)) { in pbuf_header_impl()
714 p->payload = (u8_t *)p->payload - header_size_increment; in pbuf_header_impl()
716 p->payload = (u8_t *)p->payload - header_size_increment; in pbuf_header_impl()
728 p->len += header_size_increment; in pbuf_header_impl()
729 p->tot_len += header_size_increment; in pbuf_header_impl()
732 (void *)payload, (void *)p->payload, header_size_increment)); in pbuf_header_impl()
758 pbuf_header(struct pbuf *p, s16_t header_size_increment) in pbuf_header() argument
760 return pbuf_header_impl(p, header_size_increment, 0); in pbuf_header()
768 pbuf_header_force(struct pbuf *p, s16_t header_size_increment) in pbuf_header_force() argument
770 return pbuf_header_impl(p, header_size_increment, 1); in pbuf_header_force()
808 pbuf_free(struct pbuf *p) in pbuf_free() argument
814 if (p == NULL) { in pbuf_free()
815 LWIP_ASSERT("p != NULL", p != NULL); in pbuf_free()
821 LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free(%p)\n", (void *)p)); in pbuf_free()
826 p->type == PBUF_RAM || p->type == PBUF_ROM || in pbuf_free()
827 p->type == PBUF_REF || p->type == PBUF_POOL); in pbuf_free()
832 while (p != NULL) { in pbuf_free()
840 LWIP_ASSERT("pbuf_free: p->ref > 0", p->ref > 0); in pbuf_free()
842 ref = --(p->ref); in pbuf_free()
847 q = p->next; in pbuf_free()
848 LWIP_DEBUGF( PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free: deallocating %p\n", (void *)p)); in pbuf_free()
849 type = p->type; in pbuf_free()
852 if ((p->flags & PBUF_FLAG_IS_CUSTOM) != 0) { in pbuf_free()
853 struct pbuf_custom *pc = (struct pbuf_custom*)p; in pbuf_free()
855 pc->custom_free_function(p); in pbuf_free()
862 … memp_free((p->mb_flags & PBUF_FLAG_POOL_SMALL) ? MEMP_PBUF_POOL_SMALL : MEMP_PBUF_POOL, p); in pbuf_free()
864 memp_free(MEMP_PBUF_POOL, p); in pbuf_free()
868 memp_free(MEMP_PBUF, p); in pbuf_free()
871 mem_free(p); in pbuf_free()
876 p = q; in pbuf_free()
880 …( PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free: %p has ref %"U16_F", ending here.\n", (void *)p, ref)); in pbuf_free()
882 p = NULL; in pbuf_free()
897 pbuf_clen(const struct pbuf *p) in pbuf_clen() argument
902 while (p != NULL) { in pbuf_clen()
904 p = p->next; in pbuf_clen()
917 pbuf_ref(struct pbuf *p) in pbuf_ref() argument
920 if (p != NULL) { in pbuf_ref()
921 SYS_ARCH_INC(p->ref, 1); in pbuf_ref()
938 struct pbuf *p; in pbuf_cat() local
944 for (p = h; p->next != NULL; p = p->next) { in pbuf_cat()
946 p->tot_len += t->tot_len; in pbuf_cat()
949 LWIP_ASSERT("p->tot_len == p->len (of last pbuf in chain)", p->tot_len == p->len); in pbuf_cat()
950 LWIP_ASSERT("p->next == NULL", p->next == NULL); in pbuf_cat()
952 p->tot_len += t->tot_len; in pbuf_cat()
954 p->next = t; in pbuf_cat()
995 pbuf_dechain(struct pbuf *p) in pbuf_dechain() argument
1000 q = p->next; in pbuf_dechain()
1004 LWIP_ASSERT("p->tot_len == p->len + q->tot_len", q->tot_len == p->tot_len - p->len); in pbuf_dechain()
1006 q->tot_len = p->tot_len - p->len; in pbuf_dechain()
1008 p->next = NULL; in pbuf_dechain()
1010 p->tot_len = p->len; in pbuf_dechain()
1021 LWIP_ASSERT("p->tot_len == p->len", p->tot_len == p->len); in pbuf_dechain()
1113 const struct pbuf *p; in pbuf_copy_partial() local
1124 for (p = buf; len != 0 && p != NULL; p = p->next) { in pbuf_copy_partial()
1125 if ((offset != 0) && (offset >= p->len)) { in pbuf_copy_partial()
1127 offset -= p->len; in pbuf_copy_partial()
1130 buf_copy_len = p->len - offset; in pbuf_copy_partial()
1135 MEMCPY(&((char*)dataptr)[left], &((char*)p->payload)[offset], buf_copy_len); in pbuf_copy_partial()
1158 void pbuf_split_64k(struct pbuf *p, struct pbuf **rest) in pbuf_split_64k() argument
1161 if ((p != NULL) && (p->next != NULL)) { in pbuf_split_64k()
1162 u16_t tot_len_front = p->len; in pbuf_split_64k()
1163 struct pbuf *i = p; in pbuf_split_64k()
1164 struct pbuf *r = p->next; in pbuf_split_64k()
1178 for (i = p; i != NULL; i = i->next) { in pbuf_split_64k()
1183 if (p->flags & PBUF_FLAG_TCP_FIN) { in pbuf_split_64k()
1242 struct pbuf *p; in pbuf_take() local
1256 for (p = buf; total_copy_len != 0; p = p->next) { in pbuf_take()
1257 LWIP_ASSERT("pbuf_take: invalid pbuf", p != NULL); in pbuf_take()
1259 if (buf_copy_len > p->len) { in pbuf_take()
1261 buf_copy_len = p->len; in pbuf_take()
1264 MEMCPY(p->payload, &((const char*)dataptr)[copied_total], buf_copy_len); in pbuf_take()
1320 pbuf_coalesce(struct pbuf *p, pbuf_layer layer) in pbuf_coalesce() argument
1324 if (p->next == NULL) { in pbuf_coalesce()
1325 return p; in pbuf_coalesce()
1327 q = pbuf_alloc(layer, p->tot_len, PBUF_RAM); in pbuf_coalesce()
1330 return p; in pbuf_coalesce()
1332 err = pbuf_copy(q, p); in pbuf_coalesce()
1337 pbuf_free(p); in pbuf_coalesce()
1355 pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr, in pbuf_fill_chksum() argument
1361 LWIP_ASSERT("p != NULL", p != NULL); in pbuf_fill_chksum()
1366 if ((start_offset >= p->len) || (start_offset + len > p->len)) { in pbuf_fill_chksum()
1370 dst_ptr = ((char*)p->payload) + start_offset; in pbuf_fill_chksum()
1392 pbuf_get_at(const struct pbuf* p, u16_t offset) in pbuf_get_at() argument
1394 int ret = pbuf_try_get_at(p, offset); in pbuf_get_at()
1410 pbuf_try_get_at(const struct pbuf* p, u16_t offset) in pbuf_try_get_at() argument
1413 const struct pbuf* q = pbuf_skip_const(p, offset, &q_idx); in pbuf_try_get_at()
1432 pbuf_put_at(struct pbuf* p, u16_t offset, u8_t data) in pbuf_put_at() argument
1435 struct pbuf* q = pbuf_skip(p, offset, &q_idx); in pbuf_put_at()
1455 pbuf_memcmp(const struct pbuf* p, u16_t offset, const void* s2, u16_t n) in pbuf_memcmp() argument
1458 const struct pbuf* q = p; in pbuf_memcmp()
1462 if(p->tot_len < (offset + n)) { in pbuf_memcmp()
1497 pbuf_memfind(const struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset) in pbuf_memfind() argument
1500 u16_t max = p->tot_len - mem_len; in pbuf_memfind()
1501 if (p->tot_len >= mem_len + start_offset) { in pbuf_memfind()
1503 u16_t plus = pbuf_memcmp(p, i, mem, mem_len); in pbuf_memfind()
1524 pbuf_strstr(const struct pbuf* p, const char* substr) in pbuf_strstr() argument
1527 if ((substr == NULL) || (substr[0] == 0) || (p->tot_len == 0xFFFF)) { in pbuf_strstr()
1534 return pbuf_memfind(p, substr, (u16_t)substr_len, 0); in pbuf_strstr()