XXX we could do a better algorithm here... */
| 203 | |
| 204 | /* XXX we could do a better algorithm here... */ |
| 205 | int |
| 206 | cirbuf_align_right(struct cirbuf * cbuf) |
| 207 | { |
| 208 | if (!cbuf) |
| 209 | return -EINVAL; |
| 210 | |
| 211 | if (cbuf->start >= cbuf->maxlen/2) { |
| 212 | while (cbuf->end != cbuf->maxlen-1) { |
| 213 | __cirbuf_shift_left(cbuf); |
| 214 | } |
| 215 | } |
| 216 | else { |
| 217 | while (cbuf->start != cbuf->maxlen-1) { |
| 218 | __cirbuf_shift_right(cbuf); |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | return 0; |
| 223 | } |
| 224 | |
| 225 | /* buffer del */ |
| 226 |