由买买提看人间百态

topics

全部话题 - 话题: bcbuffer
(共0页)
k**l
发帖数: 2966
1
来自主题: Programming版 - C++ | A memory allocation question
I use a queue (deque) to store some broadcast messages for later process.
All messages were casted to char array with certain length.
say when I got a new broadcast with length n;
char* bcbuffer = new char [n];
memcpy(bcbuffer,broadcast,n);
m_broadcastQue.push(std::pair(bcbuffer,n));
Later when I process it:
char* bcbuffer =m_broadcastQue.front().first;
int n=m_broadcastQue.front().second;
m_broadcastQue.pop();//cut the link to free queue lock
processOneBroadCast(bcbuffer, n);
delete ... 阅读全帖
i***c
发帖数: 26
2
来自主题: Programming版 - C++ | A memory allocation question
delete [] bcbuffer and delete bcbuffer are the same here I think, for char
needn't deconstruction function.
(共0页)