Skip to main content

Timeline for Circular Buffer

Current License: CC BY-SA 3.0

12 events
when toggle format what by license comment
Apr 13, 2017 at 12:40 history edited CommunityBot
replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Mar 19, 2016 at 17:44 comment added chux Let us continue this discussion in chat.
Mar 19, 2016 at 17:43 comment added chux @@LastSecondsToLive OTOH, struct circularBuffer *tmp = calloc(1, sizeof *tmp + numElements * elementSize); tmp->data = &tmp[1]; may not provide the alignment needed tmp->data when it is returned in circularBuffer_popTail(). In fact, the whole tmp->data = malloc(numElements * elementSize); idea is prone to alignment issues and may be a major fault with this curricular queue idea. The issue is that not only is each element needing elementSize, it may need a certain alignment, something not insured by your code. Hmmm, will ponder that.
Mar 19, 2016 at 17:22 comment added LastSecondsToLive Thanks, very interesting - never heard of it before, but I'm relatively new to C, so I guess that's fine...
Mar 19, 2016 at 16:28 comment added chux @LastSecondsToLive A different way to do this since C99 is with flexible array member which is an indefinite sized array at the end of a structure.
Mar 19, 2016 at 16:24 comment added chux @LastSecondsToLive For #9, struct circularBuffer *tmp = calloc(1, sizeof *tmp + numElements * elementSize); tmp->data = &tmp[1];
Mar 19, 2016 at 8:39 comment added LastSecondsToLive And how would I handle 9.? I was thinking about an array in the structure, but since I don't know the size, this won't work. How is this normally done?
Mar 18, 2016 at 22:39 vote accept LastSecondsToLive
Mar 18, 2016 at 22:38 comment added LastSecondsToLive Wow, so many great ideas. I wasn't thinking that so much could be made clearer/better. Thank you! The only thing I won't change is point 12. I explicitly need the behavior to override the old data, if new data arrives. Maybe I'll add a boolean return value to report, whether something was overwritten though. Thanks again :)
Mar 18, 2016 at 20:53 history edited chux CC BY-SA 3.0
added 296 characters in body
Mar 18, 2016 at 20:33 history edited chux CC BY-SA 3.0
added 209 characters in body
Mar 18, 2016 at 20:27 history answered chux CC BY-SA 3.0