sniperHW / chuck

high performance and easily use asynchronous network library for C/Lua
52 stars 32 forks source link

reader_check_size #8

Closed zhuoyikang closed 9 years ago

zhuoyikang commented 9 years ago

static inline int32_t reader_check_size(buffer_reader *reader,uint32_t size) { uint32_t tmp = reader->pos + size; return reader->cur->size >= tmp && tmp > size; }

初始化的时候reader->pos为0,是不是应该是 tmp>=size ?

return reader->cur->size >= tmp && tmp >= size;

sniperHW commented 9 years ago

tmp > size 是判断 reader->pos + size是否出现回绕的

sniperHW commented 9 years ago

应该加个assert(size > 0);检查是否有0空间应该是逻辑错误