On Mon, 2010-12-20, Johan Corveleyn wrote: > New macro version (increment only, decrement is similar): > [[[ > /* For all files in the FILE array, increment the curp pointer. If a file > * points before the beginning of file, let it point at the first byte again. > * If the end of the current chunk is reached, read the next chunk in the > * buffer and point curp to the start of the chunk. If EOF is reached, set > * curp equal to endp to indicate EOF. */ > #define increment_pointers(all_files, files_len, pool) \ > do { \ > int i; \ > \ > for (i = 0; i < files_len; i++) \ > { \ > if (all_files[i]->chunk == -1) /* indicates before beginning of file */\ > all_files[i]->chunk = 0; /* point to beginning of file again */ \ > else if (all_files[i]->curp != all_files[i]->endp - 1) \ > all_files[i]->curp++; \
Hi Johan. Here you are having to test for two special cases every time: chunk==-1 and curp==endp-1. I would suggest changing the specification of "before beginning of file" to include the promise that curp==endp-1, so that you don't have to use a separate test here and can instead test for this special case within increment_chunk(). - Julian