| 508 | } |
| 509 | |
| 510 | struct compressor * |
| 511 | compressor_init(compressor_cb_t cb, int format, size_t maxiosize, int level, |
| 512 | void *arg) |
| 513 | { |
| 514 | struct compressor_methods **iter; |
| 515 | struct compressor *s; |
| 516 | void *priv; |
| 517 | |
| 518 | SET_FOREACH(iter, compressors) { |
| 519 | if ((*iter)->format == format) |
| 520 | break; |
| 521 | } |
| 522 | if (iter == SET_LIMIT(compressors)) |
| 523 | return (NULL); |
| 524 | |
| 525 | priv = (*iter)->init(maxiosize, level); |
| 526 | if (priv == NULL) |
| 527 | return (NULL); |
| 528 | |
| 529 | s = malloc(sizeof(*s), M_COMPRESS, M_WAITOK | M_ZERO); |
| 530 | s->methods = (*iter); |
| 531 | s->priv = priv; |
| 532 | s->cb = cb; |
| 533 | s->arg = arg; |
| 534 | return (s); |
| 535 | } |
| 536 | |
| 537 | void |
| 538 | compressor_reset(struct compressor *stream) |
no test coverage detected