sds sdsRemoveFreeSpace(sds s) { struct sdshdr *sh; sh = (void*)(s-(sizeof(struct sdshdr))); sh = realloc(sh,sizeof(struct sdshdr)+sh->len+1); //这一句源函数是zrealloc()函数,我替换成realloc()函数。 // sh->free; return sh->buf; }
删掉sds字符串中的空白部分,即将free的大小置为0.
将字符串中的空白部分删除这么写,是为了什么呢?真的让人难以置信。函数