X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=fifo.c;h=ac0d21576dcf9fce5192945472cb7dd04f624bff;hp=df165f743f89912e9e37a55eea94f12966aa34a2;hb=a8d8f8286fa125c88baa20906e3f865bea1a08d2;hpb=f12b323f5d5ca40cd966ebbcfbbfcdf0a1fc229e diff --git a/fifo.c b/fifo.c index df165f74..ac0d2157 100644 --- a/fifo.c +++ b/fifo.c @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ @@ -24,6 +24,7 @@ #include #include "fifo.h" +#include "minmax.h" struct fifo *fifo_alloc(unsigned int size) { @@ -31,7 +32,7 @@ struct fifo *fifo_alloc(unsigned int size) fifo = malloc(sizeof(struct fifo)); if (!fifo) - return 0; + return NULL; fifo->buffer = malloc(size); fifo->size = size; @@ -69,23 +70,23 @@ unsigned int fifo_put(struct fifo *fifo, void *buffer, unsigned int len) return len; } -unsigned int fifo_get(struct fifo *fifo, void *buffer, unsigned int len) +unsigned int fifo_get(struct fifo *fifo, void *buf, unsigned int len) { len = min(len, fifo->in - fifo->out); - if (buffer) { + if (buf) { unsigned int l; /* * first get the data from fifo->out until the end of the buffer */ l = min(len, fifo->size - (fifo->out & (fifo->size - 1))); - memcpy(buffer, fifo->buffer + (fifo->out & (fifo->size - 1)),l); + memcpy(buf, fifo->buffer + (fifo->out & (fifo->size - 1)), l); /* * then get the rest (if any) from the beginning of the buffer */ - memcpy(buffer + l, fifo->buffer, len - l); + memcpy(buf + l, fifo->buffer, len - l); } fifo->out += len;