"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cbuffer.c" between
lzlib-1.12.tar.lz and lzlib-1.13.tar.lz

About: Lzlib is a data compression library providing in-memory LZMA compression and decompression functions using the lzip format.

cbuffer.c  (lzlib-1.12.tar.lz):cbuffer.c  (lzlib-1.13.tar.lz)
/* Lzlib - Compression library for the lzip format /* Lzlib - Compression library for the lzip format
Copyright (C) 2009-2021 Antonio Diaz Diaz. Copyright (C) 2009-2022 Antonio Diaz Diaz.
This library is free software. Redistribution and use in source and This library is free software. Redistribution and use in source and
binary forms, with or without modification, are permitted provided binary forms, with or without modification, are permitted provided
that the following conditions are met: that the following conditions are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
notice, this list of conditions, and the following disclaimer. notice, this list of conditions, and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions, and the following disclaimer in the notice, this list of conditions, and the following disclaimer in the
skipping to change at line 77 skipping to change at line 77
static bool Cb_unread_data( struct Circular_buffer * const cb, static bool Cb_unread_data( struct Circular_buffer * const cb,
const unsigned size ) const unsigned size )
{ {
if( size > Cb_free_bytes( cb ) ) return false; if( size > Cb_free_bytes( cb ) ) return false;
if( cb->get >= size ) cb->get -= size; if( cb->get >= size ) cb->get -= size;
else cb->get = cb->buffer_size - size + cb->get; else cb->get = cb->buffer_size - size + cb->get;
return true; return true;
} }
/* Copies up to 'out_size' bytes to 'out_buffer' and updates 'get'. /* Copy up to 'out_size' bytes to 'out_buffer' and update 'get'.
If 'out_buffer' is null, the bytes are discarded. If 'out_buffer' is null, the bytes are discarded.
Returns the number of bytes copied or discarded. Return the number of bytes copied or discarded.
*/ */
static unsigned Cb_read_data( struct Circular_buffer * const cb, static unsigned Cb_read_data( struct Circular_buffer * const cb,
uint8_t * const out_buffer, uint8_t * const out_buffer,
const unsigned out_size ) const unsigned out_size )
{ {
unsigned size = 0; unsigned size = 0;
if( out_size == 0 ) return 0; if( out_size == 0 ) return 0;
if( cb->get > cb->put ) if( cb->get > cb->put )
{ {
size = min( cb->buffer_size - cb->get, out_size ); size = min( cb->buffer_size - cb->get, out_size );
skipping to change at line 110 skipping to change at line 110
if( size2 > 0 ) if( size2 > 0 )
{ {
if( out_buffer ) memcpy( out_buffer + size, cb->buffer + cb->get, size2 ); if( out_buffer ) memcpy( out_buffer + size, cb->buffer + cb->get, size2 );
cb->get += size2; cb->get += size2;
size += size2; size += size2;
} }
} }
return size; return size;
} }
/* Copies up to 'in_size' bytes from 'in_buffer' and updates 'put'. /* Copy up to 'in_size' bytes from 'in_buffer' and update 'put'.
Returns the number of bytes copied. Return the number of bytes copied.
*/ */
static unsigned Cb_write_data( struct Circular_buffer * const cb, static unsigned Cb_write_data( struct Circular_buffer * const cb,
const uint8_t * const in_buffer, const uint8_t * const in_buffer,
const unsigned in_size ) const unsigned in_size )
{ {
unsigned size = 0; unsigned size = 0;
if( in_size == 0 ) return 0; if( in_size == 0 ) return 0;
if( cb->put >= cb->get ) if( cb->put >= cb->get )
{ {
size = min( cb->buffer_size - cb->put - (cb->get == 0), in_size ); size = min( cb->buffer_size - cb->put - (cb->get == 0), in_size );
 End of changes. 4 change blocks. 
5 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)