One line of mimalloc's stats table, logged as it comes. */
| 929 | |
| 930 | /* One line of mimalloc's stats table, logged as it comes. */ |
| 931 | static void mem_allocator_stats_line(const char *msg, void *arg) { |
| 932 | if (!msg || !msg[0]) { |
| 933 | return; |
| 934 | } |
| 935 | char line[512]; |
| 936 | size_t n = 0; |
| 937 | for (const char *p = msg; *p && n + 1 < sizeof(line); p++) { |
| 938 | line[n++] = (*p == '\n' || *p == '\r' || *p == '\t') ? ' ' : *p; |
| 939 | } |
| 940 | line[n] = '\0'; |
| 941 | /* trailing blanks make the log unreadable; trim */ |
| 942 | while (n > 0 && line[n - 1] == ' ') { |
| 943 | line[--n] = '\0'; |
| 944 | } |
| 945 | if (line[0] == '\0') { |
| 946 | return; |
| 947 | } |
| 948 | cbm_log_info("mem.allocator.stats", "tag", (const char *)arg, "line", line); |
| 949 | } |
| 950 | |
| 951 | void cbm_mem_allocator_stats_log(const char *tag) { |
| 952 | char enabled[CBM_SZ_16]; |
nothing calls this directly
no outgoing calls
no test coverage detected