HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
willemt
cbuffer
C2016–2020
willemt / cbuffer

cbuffer

A circular buffer written in C using Posix calls to create a contiguously mapped memory space. BSD Licensed.

4Distinct people
4Mentions
0Explicit recommenders
274GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

A circular buffer written in C using Posix calls to create a contiguously mapped memory space. BSD Licensed.

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 1:49:46 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year4 dated mentions

Observed mentions: 2016-12-14 15:58:04 UTC to 2020-09-28 17:03:45 UTC.

0122016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20162017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments20182019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 2 mentions; 1 submissions, 1 comments2020

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC101
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC101
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC000
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC000
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC211

What Hacker News says

4 sources
No. Suppose I have a ring buffer, and the dashes represent the first page, and the tildes represent the second page (which just aliases the first page), and each dash/tilde represents a single byte: https://i.imgur.com/NfZTICG.png p = memory address of the beginning of the first page o = the head index s = the size C = capacity = size of page Now suppose I wish to append 10 bytes. I would simply do: memcpy(p + (o + s) % C, input_data, 10) s += 10 Or, to remove 15 bytes from the beginning, I would do: o = (o + 15) % C s -= 15 Because any given 'slice' of the ring buffer's space can be represented as a contiguous range of memory (thanks to the second page), I can use the already optimized memcpy routine for adding and removing data at the beginning or end of the buffer. But I still need to make sure that the head index is always updated mod
Read the rest
ulo the capacity, or it will increment unboundedly, as you say. As you can tell in the above example, I'm not adding/removing individual bytes. Magic ring buffers only make sense when you frequently need to add or remove several elements from the ends of the buffer. It's particularly well suited for when you have a stream of data and need to operate on it in chunks. Here's a GitHub repo that contains an implementation of the magic ring buffer: https://github.com/willemt/cbuffer
In The mmap() copy-on-write trick: reducing memory usage of array copies
Read the rest
In A Peek at GNU Radio’s Buffer Architecture

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.