Lines Matching refs:buf

62 	struct tcp_send_buffer *buf;  in SBInit()  local
65 buf = SBDequeue(sbm->freeq); in SBInit()
66 if (!buf) { in SBInit()
67 buf = (struct tcp_send_buffer *)malloc(sizeof(struct tcp_send_buffer)); in SBInit()
68 if (!buf) { in SBInit()
72 buf->data = MPAllocateChunk(sbm->mp); in SBInit()
73 if (!buf->data) { in SBInit()
75 free(buf); in SBInit()
81 buf->head = buf->data; in SBInit()
83 buf->head_off = buf->tail_off = 0; in SBInit()
84 buf->len = buf->cum_len = 0; in SBInit()
85 buf->size = sbm->chunk_size; in SBInit()
87 buf->init_seq = buf->head_seq = init_seq; in SBInit()
89 return buf; in SBInit()
93 SBFree(sb_manager_t sbm, struct tcp_send_buffer *buf) in SBFree() argument
95 if (!buf) in SBFree()
98 SBEnqueue(sbm->freeq, buf); in SBFree()
102 SBPut(sb_manager_t sbm, struct tcp_send_buffer *buf, const void *data, size_t len) in SBPut() argument
110 to_put = MIN(len, buf->size - buf->len); in SBPut()
115 if (buf->tail_off + to_put < buf->size) { in SBPut()
117 memcpy(buf->data + buf->tail_off, data, to_put); in SBPut()
118 buf->tail_off += to_put; in SBPut()
121 memmove(buf->data, buf->head, buf->len); in SBPut()
122 buf->head = buf->data; in SBPut()
123 buf->head_off = 0; in SBPut()
124 memcpy(buf->head + buf->len, data, to_put); in SBPut()
125 buf->tail_off = buf->len + to_put; in SBPut()
127 buf->len += to_put; in SBPut()
128 buf->cum_len += to_put; in SBPut()
134 SBRemove(sb_manager_t sbm, struct tcp_send_buffer *buf, size_t len) in SBRemove() argument
141 to_remove = MIN(len, buf->len); in SBRemove()
146 buf->head_off += to_remove; in SBRemove()
147 buf->head = buf->data + buf->head_off; in SBRemove()
148 buf->head_seq += to_remove; in SBRemove()
149 buf->len -= to_remove; in SBRemove()
152 if (buf->len == 0 && buf->head_off > 0) { in SBRemove()
153 buf->head = buf->data; in SBRemove()
154 buf->head_off = buf->tail_off = 0; in SBRemove()