Lines Matching refs:buf
65 struct netbuf *buf; in netbuf_new() local
67 buf = (struct netbuf *)memp_malloc(MEMP_NETBUF); in netbuf_new()
68 if (buf != NULL) { in netbuf_new()
69 memset(buf, 0, sizeof(struct netbuf)); in netbuf_new()
71 return buf; in netbuf_new()
81 netbuf_delete(struct netbuf *buf) in netbuf_delete() argument
83 if (buf != NULL) { in netbuf_delete()
84 if (buf->p != NULL) { in netbuf_delete()
85 pbuf_free(buf->p); in netbuf_delete()
86 buf->p = buf->ptr = NULL; in netbuf_delete()
88 memp_free(MEMP_NETBUF, buf); in netbuf_delete()
102 netbuf_alloc(struct netbuf *buf, u16_t size) in netbuf_alloc() argument
104 LWIP_ERROR("netbuf_alloc: invalid buf", (buf != NULL), return NULL;); in netbuf_alloc()
107 if (buf->p != NULL) { in netbuf_alloc()
108 pbuf_free(buf->p); in netbuf_alloc()
110 buf->p = pbuf_alloc(PBUF_TRANSPORT, size, PBUF_RAM); in netbuf_alloc()
111 if (buf->p == NULL) { in netbuf_alloc()
115 (buf->p->len >= size)); in netbuf_alloc()
116 buf->ptr = buf->p; in netbuf_alloc()
117 return buf->p->payload; in netbuf_alloc()
127 netbuf_free(struct netbuf *buf) in netbuf_free() argument
129 LWIP_ERROR("netbuf_free: invalid buf", (buf != NULL), return;); in netbuf_free()
130 if (buf->p != NULL) { in netbuf_free()
131 pbuf_free(buf->p); in netbuf_free()
133 buf->p = buf->ptr = NULL; in netbuf_free()
135 buf->flags = 0; in netbuf_free()
136 buf->toport_chksum = 0; in netbuf_free()
151 netbuf_ref(struct netbuf *buf, const void *dataptr, u16_t size) in netbuf_ref() argument
153 LWIP_ERROR("netbuf_ref: invalid buf", (buf != NULL), return ERR_ARG;); in netbuf_ref()
154 if (buf->p != NULL) { in netbuf_ref()
155 pbuf_free(buf->p); in netbuf_ref()
157 buf->p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_REF); in netbuf_ref()
158 if (buf->p == NULL) { in netbuf_ref()
159 buf->ptr = NULL; in netbuf_ref()
162 ((struct pbuf_rom *)buf->p)->payload = dataptr; in netbuf_ref()
163 buf->p->len = buf->p->tot_len = size; in netbuf_ref()
164 buf->ptr = buf->p; in netbuf_ref()
196 netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len) in netbuf_data() argument
198 LWIP_ERROR("netbuf_data: invalid buf", (buf != NULL), return ERR_ARG;); in netbuf_data()
202 if (buf->ptr == NULL) { in netbuf_data()
205 *dataptr = buf->ptr->payload; in netbuf_data()
206 *len = buf->ptr->len; in netbuf_data()
222 netbuf_next(struct netbuf *buf) in netbuf_next() argument
224 LWIP_ERROR("netbuf_next: invalid buf", (buf != NULL), return -1;); in netbuf_next()
225 if (buf->ptr->next == NULL) { in netbuf_next()
228 buf->ptr = buf->ptr->next; in netbuf_next()
229 if (buf->ptr->next == NULL) { in netbuf_next()
244 netbuf_first(struct netbuf *buf) in netbuf_first() argument
246 LWIP_ERROR("netbuf_first: invalid buf", (buf != NULL), return;); in netbuf_first()
247 buf->ptr = buf->p; in netbuf_first()