From ee4d705deade2e9d0cb719ba4bf9518b6d238117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rik=20B=C3=A4hnemann?= Date: Mon, 23 Nov 2020 19:23:17 +0100 Subject: [PATCH 1/3] Expose head and tail functions. --- RingBufCPP.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/RingBufCPP.h b/RingBufCPP.h index 2ad61cf..7ef5864 100644 --- a/RingBufCPP.h +++ b/RingBufCPP.h @@ -140,7 +140,15 @@ bool isEmpty() const return ret; } -protected: +/** +* Returns the index in the array of the newest element +* Return: index in array of element +*/ +size_t getHead() const +{ + return _head; +} + /** * Calculates the index in the array of the oldest element * Return: index in array of element @@ -150,6 +158,7 @@ size_t getTail() const return (_head + (MaxElements - _numElements))%MaxElements; } +protected: // underlying array Type _buf[MaxElements]; From 738ab5d53d51996e9408de2ad9c851a2981a2a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rik=20B=C3=A4hnemann?= Date: Tue, 24 Nov 2020 22:55:34 +0100 Subject: [PATCH 2/3] Revert "Expose head and tail functions." This reverts commit ee4d705deade2e9d0cb719ba4bf9518b6d238117. --- RingBufCPP.h | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/RingBufCPP.h b/RingBufCPP.h index 7ef5864..2ad61cf 100644 --- a/RingBufCPP.h +++ b/RingBufCPP.h @@ -140,15 +140,7 @@ bool isEmpty() const return ret; } -/** -* Returns the index in the array of the newest element -* Return: index in array of element -*/ -size_t getHead() const -{ - return _head; -} - +protected: /** * Calculates the index in the array of the oldest element * Return: index in array of element @@ -158,7 +150,6 @@ size_t getTail() const return (_head + (MaxElements - _numElements))%MaxElements; } -protected: // underlying array Type _buf[MaxElements]; From cc35cbb413b2fac17c62da7d84d5aef3b8522429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rik=20B=C3=A4hnemann?= Date: Wed, 25 Nov 2020 01:06:34 +0100 Subject: [PATCH 3/3] Empty pull. --- RingBufCPP.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/RingBufCPP.h b/RingBufCPP.h index 2ad61cf..d1c3732 100644 --- a/RingBufCPP.h +++ b/RingBufCPP.h @@ -59,7 +59,10 @@ bool pull(Type *dest) { if (!isEmpty()) { tail = getTail(); - *dest = _buf[tail]; + if (dest) + { + *dest = _buf[tail]; + } _numElements--; ret = true;