You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* Try with buffers two times bigger every time we fail to * fit the string in the current buffer size. */while(1) {
buf[buflen-2] ='\0';
va_copy(cpy,ap);
// T = O(N)vsnprintf(buf, buflen, fmt, cpy);
if (buf[buflen-2] !='\0') {
if (buf!=staticbuf) zfree(buf);
buflen *= 2;
buf=zmalloc(buflen);
if (buf==NULL) returnNULL;
continue;
}
break;
}
buf 每次是两倍的长度增长, 时间复杂度应该是 n*logn 吧
n 代表 fmt 字符串的长度
The text was updated successfully, but these errors were encountered:
源码中对
sdscatvprintf
这个函数的时间复杂度分析buf 每次是两倍的长度增长, 时间复杂度应该是
n*logn
吧n 代表 fmt 字符串的长度
The text was updated successfully, but these errors were encountered: