Lines Matching refs:p
209 struct pbuf *p, *q, *r; in pbuf_alloc() local
239 p = (struct pbuf *)memp_malloc(MEMP_PBUF_POOL); in pbuf_alloc()
240 LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc: allocated pbuf %p\n", (void *)p)); in pbuf_alloc()
241 if (p == NULL) { in pbuf_alloc()
245 p->type = type; in pbuf_alloc()
246 p->next = NULL; in pbuf_alloc()
249 p->payload = LWIP_MEM_ALIGN((void *)((u8_t *)p + (SIZEOF_STRUCT_PBUF + offset))); in pbuf_alloc()
251 ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0); in pbuf_alloc()
253 p->tot_len = length; in pbuf_alloc()
255 p->len = LWIP_MIN(length, PBUF_POOL_BUFSIZE_ALIGNED - LWIP_MEM_ALIGN_SIZE(offset)); in pbuf_alloc()
257 ((u8_t*)p->payload + p->len <= in pbuf_alloc()
258 (u8_t*)p + SIZEOF_STRUCT_PBUF + PBUF_POOL_BUFSIZE_ALIGNED)); in pbuf_alloc()
262 p->ref = 1; in pbuf_alloc()
267 r = p; in pbuf_alloc()
269 rem_len = length - p->len; in pbuf_alloc()
276 pbuf_free(p); in pbuf_alloc()
294 ((u8_t*)p->payload + p->len <= in pbuf_alloc()
295 (u8_t*)p + SIZEOF_STRUCT_PBUF + PBUF_POOL_BUFSIZE_ALIGNED)); in pbuf_alloc()
308 …p = (struct pbuf*)mem_malloc(LWIP_MEM_ALIGN_SIZE(SIZEOF_STRUCT_PBUF + offset) + LWIP_MEM_ALIGN_SIZ… in pbuf_alloc()
309 if (p == NULL) { in pbuf_alloc()
313 p->payload = LWIP_MEM_ALIGN((void *)((u8_t *)p + SIZEOF_STRUCT_PBUF + offset)); in pbuf_alloc()
314 p->len = p->tot_len = length; in pbuf_alloc()
315 p->next = NULL; in pbuf_alloc()
316 p->type = type; in pbuf_alloc()
319 ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0); in pbuf_alloc()
326 p = (struct pbuf *)memp_malloc(MEMP_PBUF); in pbuf_alloc()
327 if (p == NULL) { in pbuf_alloc()
334 p->payload = NULL; in pbuf_alloc()
335 p->len = p->tot_len = length; in pbuf_alloc()
336 p->next = NULL; in pbuf_alloc()
337 p->type = type; in pbuf_alloc()
344 p->ref = 1; in pbuf_alloc()
346 p->flags = 0; in pbuf_alloc()
347 …IP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloc(length=%"U16_F") == %p\n", length, (void *)p)); in pbuf_alloc()
348 return p; in pbuf_alloc()
367 pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type, struct pbuf_custom *p, in pbuf_alloced_custom() argument
400 p->pbuf.next = NULL; in pbuf_alloced_custom()
402 p->pbuf.payload = (u8_t *)payload_mem + LWIP_MEM_ALIGN_SIZE(offset); in pbuf_alloced_custom()
404 p->pbuf.payload = NULL; in pbuf_alloced_custom()
406 p->pbuf.flags = PBUF_FLAG_IS_CUSTOM; in pbuf_alloced_custom()
407 p->pbuf.len = p->pbuf.tot_len = length; in pbuf_alloced_custom()
408 p->pbuf.type = type; in pbuf_alloced_custom()
409 p->pbuf.ref = 1; in pbuf_alloced_custom()
410 return &p->pbuf; in pbuf_alloced_custom()
430 pbuf_realloc(struct pbuf *p, u16_t new_len) in pbuf_realloc() argument
436 LWIP_ASSERT("pbuf_realloc: p != NULL", p != NULL); in pbuf_realloc()
437 LWIP_ASSERT("pbuf_realloc: sane p->type", p->type == PBUF_POOL || in pbuf_realloc()
438 p->type == PBUF_ROM || in pbuf_realloc()
439 p->type == PBUF_RAM || in pbuf_realloc()
440 p->type == PBUF_REF); in pbuf_realloc()
443 if (new_len >= p->tot_len) { in pbuf_realloc()
450 grow = new_len - p->tot_len; in pbuf_realloc()
454 q = p; in pbuf_realloc()
511 pbuf_header(struct pbuf *p, s16_t header_size_increment) in pbuf_header() argument
517 LWIP_ASSERT("p != NULL", p != NULL); in pbuf_header()
518 if ((header_size_increment == 0) || (p == NULL)) { in pbuf_header()
525 LWIP_ERROR("increment_magnitude <= p->len", (increment_magnitude <= p->len), return 1;); in pbuf_header()
533 p->type == PBUF_RAM || p->type == PBUF_POOL); in pbuf_header()
536 (u8_t *)p->payload - increment_magnitude >= (u8_t *)p + SIZEOF_STRUCT_PBUF); in pbuf_header()
540 type = p->type; in pbuf_header()
542 payload = p->payload; in pbuf_header()
547 p->payload = (u8_t *)p->payload - header_size_increment; in pbuf_header()
549 if ((u8_t *)p->payload < (u8_t *)p + SIZEOF_STRUCT_PBUF) { in pbuf_header()
552 (void *)p->payload, (void *)(p + 1))); in pbuf_header()
554 p->payload = payload; in pbuf_header()
561 if ((header_size_increment < 0) && (increment_magnitude <= p->len)) { in pbuf_header()
563 p->payload = (u8_t *)p->payload - header_size_increment; in pbuf_header()
575 p->len += header_size_increment; in pbuf_header()
576 p->tot_len += header_size_increment; in pbuf_header()
579 (void *)payload, (void *)p->payload, header_size_increment)); in pbuf_header()
618 pbuf_free(struct pbuf *p) in pbuf_free() argument
624 if (p == NULL) { in pbuf_free()
625 LWIP_ASSERT("p != NULL", p != NULL); in pbuf_free()
631 LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free(%p)\n", (void *)p)); in pbuf_free()
636 p->type == PBUF_RAM || p->type == PBUF_ROM || in pbuf_free()
637 p->type == PBUF_REF || p->type == PBUF_POOL); in pbuf_free()
642 while (p != NULL) { in pbuf_free()
650 LWIP_ASSERT("pbuf_free: p->ref > 0", p->ref > 0); in pbuf_free()
652 ref = --(p->ref); in pbuf_free()
657 q = p->next; in pbuf_free()
658 LWIP_DEBUGF( PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free: deallocating %p\n", (void *)p)); in pbuf_free()
659 type = p->type; in pbuf_free()
662 if ((p->flags & PBUF_FLAG_IS_CUSTOM) != 0) { in pbuf_free()
663 struct pbuf_custom *pc = (struct pbuf_custom*)p; in pbuf_free()
665 pc->custom_free_function(p); in pbuf_free()
671 memp_free(MEMP_PBUF_POOL, p); in pbuf_free()
674 memp_free(MEMP_PBUF, p); in pbuf_free()
677 mem_free(p); in pbuf_free()
682 p = q; in pbuf_free()
686 …( PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_free: %p has ref %"U16_F", ending here.\n", (void *)p, ref)); in pbuf_free()
688 p = NULL; in pbuf_free()
704 pbuf_clen(struct pbuf *p) in pbuf_clen() argument
709 while (p != NULL) { in pbuf_clen()
711 p = p->next; in pbuf_clen()
723 pbuf_ref(struct pbuf *p) in pbuf_ref() argument
727 if (p != NULL) { in pbuf_ref()
729 ++(p->ref); in pbuf_ref()
747 struct pbuf *p; in pbuf_cat() local
753 for (p = h; p->next != NULL; p = p->next) { in pbuf_cat()
755 p->tot_len += t->tot_len; in pbuf_cat()
758 LWIP_ASSERT("p->tot_len == p->len (of last pbuf in chain)", p->tot_len == p->len); in pbuf_cat()
759 LWIP_ASSERT("p->next == NULL", p->next == NULL); in pbuf_cat()
761 p->tot_len += t->tot_len; in pbuf_cat()
763 p->next = t; in pbuf_cat()
803 pbuf_dechain(struct pbuf *p) in pbuf_dechain() argument
808 q = p->next; in pbuf_dechain()
812 LWIP_ASSERT("p->tot_len == p->len + q->tot_len", q->tot_len == p->tot_len - p->len); in pbuf_dechain()
814 q->tot_len = p->tot_len - p->len; in pbuf_dechain()
816 p->next = NULL; in pbuf_dechain()
818 p->tot_len = p->len; in pbuf_dechain()
829 LWIP_ASSERT("p->tot_len == p->len", p->tot_len == p->len); in pbuf_dechain()
920 struct pbuf *p; in pbuf_copy_partial() local
935 for(p = buf; len != 0 && p != NULL; p = p->next) { in pbuf_copy_partial()
936 if ((offset != 0) && (offset >= p->len)) { in pbuf_copy_partial()
938 offset -= p->len; in pbuf_copy_partial()
941 buf_copy_len = p->len - offset; in pbuf_copy_partial()
945 MEMCPY(&((char*)dataptr)[left], &((char*)p->payload)[offset], buf_copy_len); in pbuf_copy_partial()
968 struct pbuf *p; in pbuf_take() local
981 for(p = buf; total_copy_len != 0; p = p->next) { in pbuf_take()
982 LWIP_ASSERT("pbuf_take: invalid pbuf", p != NULL); in pbuf_take()
984 if (buf_copy_len > p->len) { in pbuf_take()
986 buf_copy_len = p->len; in pbuf_take()
989 MEMCPY(p->payload, &((char*)dataptr)[copied_total], buf_copy_len); in pbuf_take()
1010 pbuf_coalesce(struct pbuf *p, pbuf_layer layer) in pbuf_coalesce() argument
1014 if (p->next == NULL) { in pbuf_coalesce()
1015 return p; in pbuf_coalesce()
1017 q = pbuf_alloc(layer, p->tot_len, PBUF_RAM); in pbuf_coalesce()
1020 return p; in pbuf_coalesce()
1022 err = pbuf_copy(q, p); in pbuf_coalesce()
1024 pbuf_free(p); in pbuf_coalesce()
1042 pbuf_fill_chksum(struct pbuf *p, u16_t start_offset, const void *dataptr, in pbuf_fill_chksum() argument
1048 LWIP_ASSERT("p != NULL", p != NULL); in pbuf_fill_chksum()
1053 if ((start_offset >= p->len) || (start_offset + len > p->len)) { in pbuf_fill_chksum()
1057 dst_ptr = ((char*)p->payload) + start_offset; in pbuf_fill_chksum()
1077 pbuf_get_at(struct pbuf* p, u16_t offset) in pbuf_get_at() argument
1080 struct pbuf* q = p; in pbuf_get_at()
1104 pbuf_memcmp(struct pbuf* p, u16_t offset, const void* s2, u16_t n) in pbuf_memcmp() argument
1107 struct pbuf* q = p; in pbuf_memcmp()
1140 pbuf_memfind(struct pbuf* p, const void* mem, u16_t mem_len, u16_t start_offset) in pbuf_memfind() argument
1143 u16_t max = p->tot_len - mem_len; in pbuf_memfind()
1144 if (p->tot_len >= mem_len + start_offset) { in pbuf_memfind()
1146 u16_t plus = pbuf_memcmp(p, i, mem, mem_len); in pbuf_memfind()
1168 pbuf_strstr(struct pbuf* p, const char* substr) in pbuf_strstr() argument
1171 if ((substr == NULL) || (substr[0] == 0) || (p->tot_len == 0xFFFF)) { in pbuf_strstr()
1178 return pbuf_memfind(p, substr, (u16_t)substr_len, 0); in pbuf_strstr()