
![]() |
![]() |
|
The essential difference between dynamic buffers and more straightforward means of storing binary data is that C arrays and descriptors provide essentially non-extensible buffers. Any attempt to write beyond the end of a C array results in undefined (and usually disastrous) consequences. Any attempt to write beyond the end of a descriptor results in a panic.
Heap cells may be extended, but not without limit; it may be impossible to extend a heap cell further, because the heap is exhausted, or too fragmented to permit the extension. In addition, if heap cell re-allocation results in movement of the cell, re-allocation can be unduly expensive. If re-allocation is undesirable, then a buffer could be extended by allocating a new segment in a new allocation cell. Segmented buffers have this behaviour: flat buffers use re-allocation alone.