src/lib/ppc405lib/string_stream.c
// Write the remaining tail (if any) of the circular buffer, assuming the
// buffer is not full.
Write the remaining tail (if any) of the circular buffer, assuming the
buffer is not full.
Write the remaining tail ( if any ) of the circular buffer assuming the buffer is not full .
static size_t
write_tail(StringStream* string, const void* buf, size_t size)
{
    size_t written, remainder;
    written = 0;
    if (string->next_write >= string->next_read) {
        remainder = string->size - string->next_write; 
        written = MIN(size, remainder);
        memcpy((void *)(&(string->data[string->next_write])), buf, written);
        if (written != remainder) {
            string->next_write += written;
        } else {
            string->next_write = 0;
        }
    }
    return written;
}
static size_t write_tail ( StringStream * string , const void * buf , size_t size ) { size_t written , remainder ; written = 0 ; if ( string -> next_write >= string -> next_read ) { remainder = string -> size - string -> next_write ; written = MIN ( size , remainder ) ; memcpy ( ( void * ) ( & ( string -> data [ string -> next_write ] ) ) , buf , written ) ; if ( written != remainder ) { string -> next_write += written ; } else { string -> next_write = 0 ; } } return written ; }
Write the remaining tail (if any) of the circular buffer, assuming the
buffer is not full.
Write the remaining tail ( if any ) of the circular buffer assuming the buffer is not full .
// string->size is the size of the stream(our buffer) // memcpy(void *dest, const void *src, size_t n) from /lib/memcpy.c