Skip to content

Commit

Permalink
释放队列中的空闲内存时,应该从total_num开始
Browse files Browse the repository at this point in the history
使用中的内存在 0 ~ total_num-1 范围内,而空闲内存在 total_num ~ max_num-1
处,释放空闲内存时,应该从total_num开始,而不是total_num-1,因为total_num-1处的内存已经释放过一次,再次释放会使程序崩溃。
  • Loading branch information
lc-soft committed Oct 11, 2013
1 parent eb3890c commit 02aa963
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/LCUI_Queue.c
Expand Up @@ -208,7 +208,7 @@ LCUI_API void Queue_Destroy( LCUI_Queue *queue )
/* 如果有未使用的队列成员,则把它们占用的内存空间也释放掉 */
if( queue->max_num > queue->total_num ) {
if( queue->total_num > 0 ) {
i = queue->total_num - 1;
i = queue->total_num;
} else {
i = 0;
}
Expand Down

0 comments on commit 02aa963

Please sign in to comment.