* limitations under the License.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <freerdp/utils/ringbuffer.h>
#include <stdlib.h>
#define TAG FREERDP_TAG("utils.ringbuffer")
+#ifdef WITH_DEBUG_RINGBUFFER
+#define DEBUG_RINGBUFFER(fmt, ...) WLog_DBG(TAG, fmt, ## __VA_ARGS__)
+#else
+#define DEBUG_RINGBUFFER(fmt, ...) do { } while (0)
+#endif
+
BOOL ringbuffer_init(RingBuffer* rb, size_t initialSize)
{
rb->buffer = malloc(initialSize);
rb->readPtr = rb->writePtr = 0;
rb->initialSize = rb->size = rb->freeSize = initialSize;
-
- WLog_DBG(TAG, "ringbuffer_init(%p)", rb);
-
+
+ DEBUG_RINGBUFFER("ringbuffer_init(%p)", rb);
+
return TRUE;
}
void ringbuffer_destroy(RingBuffer* rb)
{
- WLog_DBG(TAG, "ringbuffer_destroy(%p)", rb);
+ DEBUG_RINGBUFFER("ringbuffer_destroy(%p)", rb);
free(rb->buffer);
rb->buffer = NULL;
{
BYTE* newData;
- WLog_DBG(TAG, "ringbuffer_realloc(%p): targetSize: %d", rb, targetSize);
+ DEBUG_RINGBUFFER("ringbuffer_realloc(%p): targetSize: %d", rb, targetSize);
if (rb->writePtr == rb->readPtr)
{
size_t toWrite;
size_t remaining;
- WLog_DBG(TAG, "ringbuffer_write(%p): sz: %d", rb, sz);
+ DEBUG_RINGBUFFER("ringbuffer_write(%p): sz: %d", rb, sz);
if ((rb->freeSize <= sz) && !ringbuffer_realloc(rb, rb->size + sz))
return FALSE;
BYTE* ringbuffer_ensure_linear_write(RingBuffer* rb, size_t sz)
{
- WLog_DBG(TAG, "ringbuffer_ensure_linear_write(%p): sz: %d", rb, sz);
-
+ DEBUG_RINGBUFFER("ringbuffer_ensure_linear_write(%p): sz: %d", rb, sz);
+
if (rb->freeSize < sz)
{
if (!ringbuffer_realloc(rb, rb->size + sz - rb->freeSize + 32))
BOOL ringbuffer_commit_written_bytes(RingBuffer* rb, size_t sz)
{
- WLog_DBG(TAG, "ringbuffer_commit_written_bytes(%p): sz: %d", rb, sz);
+ DEBUG_RINGBUFFER("ringbuffer_commit_written_bytes(%p): sz: %d", rb, sz);
if (sz < 1)
return TRUE;
int chunkIndex = 0;
int status = 0;
- WLog_DBG(TAG, "ringbuffer_peek(%p): sz: %d", rb, sz);
+ DEBUG_RINGBUFFER("ringbuffer_peek(%p): sz: %d", rb, sz);
if (sz < 1)
return 0;
void ringbuffer_commit_read_bytes(RingBuffer* rb, size_t sz)
{
- WLog_DBG(TAG, "ringbuffer_commit_read_bytes(%p): sz: %d", rb, sz);
+ DEBUG_RINGBUFFER("ringbuffer_commit_read_bytes(%p): sz: %d", rb, sz);
if (sz < 1)
return;