Fix the bug of wrong length in xy_log()

This commit is contained in:
Aoran Zeng
2023-08-31 21:58:05 +08:00
parent f1df0ffb06
commit 22553fe751
2 changed files with 3 additions and 3 deletions

View File

@@ -81,8 +81,8 @@ xy_log (int level, const char* str)
//xy_assert ("CAN'T REACH!");
}
// -2 把中间%s减掉-1 把末尾nul减掉
size_t len = sizeof(color_fmt_str) -2 -1;
// -2 把中间%s减掉
size_t len = strlen(color_fmt_str) -2;
char* buf = malloc(strlen(str) + len + 1);
sprintf (buf, color_fmt_str, str);