src/lib/ppc405lib/string_stream.c
// Read the remaining tail (if any) of the circular buffer, assuming the
// buffer is not empty.
Read the remaining tail (if any) of the circular buffer, assuming the
buffer is not empty.
Read the remaining tail ( if any ) of the circular buffer assuming the buffer is not empty .
static size_t
read_tail(StringStream* string, void* buf, size_t size)
{
    size_t read, remainder;
    read = 0;
    if (string->next_read >= string->next_write) {
        remainder = string->size - string->next_read;
        read = MIN(size, remainder);
        memcpy(buf, (void *)(&(string->data[string->next_read])), read);
        if (read != remainder) {
            string->next_read += read;
        } else {
            string->next_read = 0;
        }
    }
    return read;
}
static size_t read_tail ( StringStream * string , void * buf , size_t size ) { size_t read , remainder ; read = 0 ; if ( string -> next_read >= string -> next_write ) { remainder = string -> size - string -> next_read ; read = MIN ( size , remainder ) ; memcpy ( buf , ( void * ) ( & ( string -> data [ string -> next_read ] ) ) , read ) ; if ( read != remainder ) { string -> next_read += read ; } else { string -> next_read = 0 ; } } return read ; }
Read the remaining tail (if any) of the circular buffer, assuming the
buffer is not empty.
Read the remaining tail ( if any ) of the circular buffer assuming the buffer is not empty .