* Allocates new buffer of given size @sz. * * Returns 0 on success. */
| 431 | * Returns 0 on success. |
| 432 | */ |
| 433 | int |
| 434 | bp_alloc(struct buf_pr *b, size_t size) |
| 435 | { |
| 436 | memset(b, 0, sizeof(struct buf_pr)); |
| 437 | |
| 438 | if ((b->buf = calloc(1, size)) == NULL) |
| 439 | return (ENOMEM); |
| 440 | |
| 441 | b->ptr = b->buf; |
| 442 | b->size = size; |
| 443 | b->avail = b->size; |
| 444 | |
| 445 | return (0); |
| 446 | } |
| 447 | |
| 448 | void |
| 449 | bp_free(struct buf_pr *b) |
no test coverage detected