Hello,
I'm programming a set of functions for bit output. This will be buffered, suppose I have two pointers:
Code:
unsigned char *buffer, *buffer_start;
The pointer buffer points to the current byte and buffer_start always points to the beginning of the dynamically allocated buffer.
My question is:
Should I introduce an integer variable buf_count that keeps the number of bytes ready in the buffer or should I calculate the number of bytes in the buffer by this formula: buffer - buffer_start? I'll need to know the number of bytes in the buffer in order to compare it with the constant BUFFER_SIZE and know when the buffer is full and ready to be written to a file.
My main concern here is speed.