On 01/04/2011 04:52 PM, Dave Hylands wrote:
On Tue, Jan 4, 2011 at 2:48 AM, Wouter Simons <lkml@woutersimons.org> wrote:
for (i = 0; i < count; i++) { if (fscanf(fd_next, "0x%X", &sample) != 1) { /* No data */ continue; }
I would change this to use unbuffered I/O routines (i.e. open/read/lseek/close) and use sscanf rather than fscanf. fopen/fread/fseek/fclose use buffering by default.
That would eliminate any buffering that the user side runtime library is doing. I suspect that because the data is buffered by the FILE * routines, even doing the seek is just re-returning the data that was read the first time around.
Thanks Dave, a quick test application shows that your solution works perfectly. This saves me a lot of overhead! Best regards, Wouter