假如有一结构体struct待存储,环形缓冲区内采用动态内存分配,那么应该采用new char[N]的方式以字节来存储结构体的字节信息,还是直接new struct[N]的方式以整体来存储结构体本身?
黄舟2017-04-17 13:14:43
It depends on what your elements are. If the element is a struct, then use a new struct array; if it is a char, then use a new char[n].
For example, for a socket buffer, usually use a CircleBuffer<uint8>
; A message queue generally uses CircleBuffer<Message>
.