summaryrefslogtreecommitdiffstats
path: root/libnetdata/circular_buffer
diff options
context:
space:
mode:
Diffstat (limited to 'libnetdata/circular_buffer')
-rw-r--r--libnetdata/circular_buffer/README.md2
-rw-r--r--libnetdata/circular_buffer/circular_buffer.c5
2 files changed, 5 insertions, 2 deletions
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);