Pulling more bitwriter changes

This commit is contained in:
Meredith L. Patterson 2012-07-27 15:29:25 -07:00
commit ee32c75837
2 changed files with 15 additions and 2 deletions

View file

@ -88,6 +88,19 @@ void h_bit_writer_put(HBitWriter* w, unsigned long long data, size_t nbits) {
}
uint8_t *h_bit_writer_get_buffer(HBitWriter* w, size_t *len);
const uint8_t *h_bit_writer_get_buffer(HBitWriter* w, size_t *len) {
assert (len != NULL);
assert (w != NULL);
// Not entirely sure how to handle a non-integral number of bytes... make it an error for now
assert (w->bit_offset == 0); // BUG: change this to some sane behaviour
*len = w->index;
return w->buf
}
void h_bit_writer_free(HBitWriter* w) {
g_free(w->buf);
g_free(w);
}
// TESTS BELOW HERE

View file

@ -475,7 +475,7 @@ void h_bit_writer_put(HBitWriter* w, unsigned long long data, size_t nbits);
* Must not free [w] until you're done with the result.
* [len] is in bytes.
*/
uint8_t *h_bit_writer_get_buffer(HBitWriter* w, size_t *len);
const uint8_t *h_bit_writer_get_buffer(HBitWriter* w, size_t *len);
/**
* TODO: Document me