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'。code