"Dr. David Alan Gilbert" <[email protected]> wrote:
>> > +    while (index >= f->buf_size) {
>> > +        int received = qemu_fill_buffer(f);
>> > +
>> > +        if (received <= 0) {
>> 
>> here, I don't know really what to do.  We just need one character, so
>> the 1st call to qemu_fill_buffer() gives it to us, or we are already on
>> problems.  i.e. no need of the while() loop.
>
> The problem is that peek_byte takes an offset, so while qemu_fill_buffer
> will get us a byte, we actually need it to get us all the bytes upto the
> offset, and that's not guaranteed from one call.

that is not a problem.

We never got a "hole" on the things that we ask for.  We ask for the
"next byte", or the "next bytes", so in qemu_peek_byte() we are
guaranteed (with current users) that we would only have to read a single
byte.

I.e. qemu_peek_{buffer,byte}(....,offset, size) means that we have
"already" peek until offset, and now we want size more bytes.

Later, Juan.

Reply via email to