alibaba / havenask

Apache License 2.0
1.6k stars 302 forks source link

这里的sizeof(char)是不是有问题? #252

Open xiaohei520321 opened 8 months ago

xiaohei520321 commented 8 months ago

https://github.com/alibaba/havenask/blob/35344cbf0c5fb2445f183538ae9f329cdc35def2/aios/autil/autil/PackDataFormatter.h#L105

size_t offsetLen = baseAddr[offset];
char *offsetAddr = baseAddr + offset + sizeof(char);
size_t offsetEndCursor = offset + sizeof(char) + offsetLen * (varNum - 1);

看代码,感觉sizeof(char) 应该换成 sizeof(offsetLen)才对啊,这里的sizeof(char)是什么含义呢

xuxijie commented 5 months ago

size_t offsetLen = baseAddr[offset]; 看这个代码,offsetLen在buf里面只占了一个字节