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()
147 netbuf_ref(struct netbuf *buf, const void *dataptr, u16_t size) in netbuf_ref() argument
149 LWIP_ERROR("netbuf_ref: invalid buf", (buf != NULL), return ERR_ARG;); in netbuf_ref()
150 if (buf->p != NULL) { in netbuf_ref()
151 pbuf_free(buf->p); in netbuf_ref()
153 buf->p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_REF); in netbuf_ref()
154 if (buf->p == NULL) { in netbuf_ref()
155 buf->ptr = NULL; in netbuf_ref()
158 ((struct pbuf_rom*)buf->p)->payload = dataptr; in netbuf_ref()
159 buf->p->len = buf->p->tot_len = size; in netbuf_ref()
160 buf->ptr = buf->p; in netbuf_ref()
192 netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len) in netbuf_data() argument
194 LWIP_ERROR("netbuf_data: invalid buf", (buf != NULL), return ERR_ARG;); in netbuf_data()
198 if (buf->ptr == NULL) { in netbuf_data()
201 *dataptr = buf->ptr->payload; in netbuf_data()
202 *len = buf->ptr->len; in netbuf_data()
218 netbuf_next(struct netbuf *buf) in netbuf_next() argument
220 LWIP_ERROR("netbuf_next: invalid buf", (buf != NULL), return -1;); in netbuf_next()
221 if (buf->ptr->next == NULL) { in netbuf_next()
224 buf->ptr = buf->ptr->next; in netbuf_next()
225 if (buf->ptr->next == NULL) { in netbuf_next()
240 netbuf_first(struct netbuf *buf) in netbuf_first() argument
242 LWIP_ERROR("netbuf_first: invalid buf", (buf != NULL), return;); in netbuf_first()
243 buf->ptr = buf->p; in netbuf_first()