From a836a244a3d2bdd4da1ee2641e3e957850668cea Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 8 May 2023 18:27:04 +0200 Subject: Adding upstream version 1.39.0. Signed-off-by: Daniel Baumann --- libnetdata/circular_buffer/README.md | 2 +- libnetdata/circular_buffer/circular_buffer.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'libnetdata/circular_buffer') diff --git a/libnetdata/circular_buffer/README.md b/libnetdata/circular_buffer/README.md index 23980dff3..c47386516 100644 --- a/libnetdata/circular_buffer/README.md +++ b/libnetdata/circular_buffer/README.md @@ -4,7 +4,7 @@ custom_edit_url: https://github.com/netdata/netdata/edit/master/libnetdata/circu sidebar_label: "Circular Buffer" learn_status: "Published" learn_topic_type: "Tasks" -learn_rel_path: "Developers/libnetdata libraries" +learn_rel_path: "Developers/libnetdata" --> # Circular Buffer diff --git a/libnetdata/circular_buffer/circular_buffer.c b/libnetdata/circular_buffer/circular_buffer.c index b2bded179..7ffe6b8bc 100644 --- a/libnetdata/circular_buffer/circular_buffer.c +++ b/libnetdata/circular_buffer/circular_buffer.c @@ -16,7 +16,10 @@ struct circular_buffer *cbuffer_new(size_t initial, size_t max, size_t *statisti } void cbuffer_free(struct circular_buffer *buf) { - if(buf && buf->statistics) + if (unlikely(!buf)) + return; + + if(buf->statistics) __atomic_sub_fetch(buf->statistics, sizeof(struct circular_buffer) + buf->size, __ATOMIC_RELAXED); freez(buf->data); -- cgit v1.2.3