3 ms·
data (startptr), endptr & capacity?! Memory might be cheap enough to waste, but more derefs do not help timings.
by downvotetruth 4y ago
data (startptr), endptr & capacity?! Memory might be cheap enough to waste, but more derefs do not help timings.
- exitb 4y agoCapacity may not be equal to size.
- JonChesterfield 4y agoThree pointers (or two and a size, or one and two sizes) is pretty standard for dynamic arrays. It lets you allocate more than one element a time when repeatedly appending one element. No checking malloc or realloc though. The anonymous struct is dubious too, though maybe being unable to pass these things to functions is a feature.
- nice_byte 4y agofunctions can work with just pointer / size / stride. think of it as stl iterators, there's no real point to be passing the container itself around. however, you can still do that, if you really want. just `typedef DYN_ARR_OF(widget) widget_array;` and now you have a name-able type, and can even have dynamic-arrays-of-dynamic-arrays (`DYN_ARR_OF(widget_array)`).