Regarding the new char alignment, it seems like it is guaranteed: http://stackoverflow.com/a/10589019 . There is a reference to the standard text and I was able to find this in C++98 and C++11.
I agree with Andrew about making a union to save a few bytes per allocation. But, we should be careful not to allocate too little (when _readNotifytCacheSize is lesser than the size of pNext). I suggest this:
Regarding the new char alignment, it seems like it is guaranteed: http:// stackoverflow. com/a/10589019 . There is a reference to the standard text and I was able to find this in C++98 and C++11.
I agree with Andrew about making a union to save a few bytes per allocation. But, we should be careful not to allocate too little (when _readNotifytCac heSize is lesser than the size of pNext). I suggest this:
struct cacheElem_t {
size_t size;
union {
struct cacheElem_t * pNext;
char buf[1];
} u;
};
Allocate: max(sizeof( cacheElem_ t), offsetof( cacheElem_ t, u) + _readNotifyCach eSize)