/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
* ---
*
* ringbuf.c: Simple ring buffer
- *
+ *
* Known contributors to this file:
- * Markus Armbruster, 2007
+ * Markus Armbruster, 2007-2009
*/
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <sys/uio.h>
-#include <unistd.h>
#include "ringbuf.h"
/*
/*
* Attempt to put SZ bytes from BUF into the ring buffer.
* Return space left in ring buffer when it fits, else don't change
- * the ring buffer and return how much space is missing.
+ * the ring buffer and return how much space is missing times -1.
*/
int
ring_putm(struct ring *r, void *buf, size_t sz)
void
ring_discard(struct ring *r, int n)
{
- assert(n <= ring_len(r));
+ assert(0 <= n && n <= ring_len(r));
r->cons += n;
}