源程序
size_t sdsAllocSize(sds s)
{
struct sdshdr *sh = (void*)(s-(sizeof(struct sdshdr)));
return sizeof(*sh)+sh->len+sh->free+1;
}
用来计算sds字符串总共的长度大小,包括为sds存储字符提供的大小,还有free的大小,还有字符串末尾的'\0'。
size_t sdsAllocSize(sds s)
{
struct sdshdr *sh = (void*)(s-(sizeof(struct sdshdr)));
return sizeof(*sh)+sh->len+sh->free+1;
}
用来计算sds字符串总共的长度大小,包括为sds存储字符提供的大小,还有free的大小,还有字符串末尾的'\0'。
转载于:https://my.oschina.net/u/1771419/blog/1619621