MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / prof_dump_write

Function prof_dump_write

deps/jemalloc/src/prof.c:1279–1309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1277}
1278
1279static bool
1280prof_dump_write(bool propagate_err, const char *s) {
1281 size_t i, slen, n;
1282
1283 cassert(config_prof);
1284
1285 i = 0;
1286 slen = strlen(s);
1287 while (i < slen) {
1288 /* Flush the buffer if it is full. */
1289 if (prof_dump_buf_end == PROF_DUMP_BUFSIZE) {
1290 if (prof_dump_flush(propagate_err) && propagate_err) {
1291 return true;
1292 }
1293 }
1294
1295 if (prof_dump_buf_end + slen - i <= PROF_DUMP_BUFSIZE) {
1296 /* Finish writing. */
1297 n = slen - i;
1298 } else {
1299 /* Write as much of s as will fit. */
1300 n = PROF_DUMP_BUFSIZE - prof_dump_buf_end;
1301 }
1302 memcpy(&prof_dump_buf[prof_dump_buf_end], &s[i], n);
1303 prof_dump_buf_end += n;
1304 i += n;
1305 }
1306 assert(i == slen);
1307
1308 return false;
1309}
1310
1311JEMALLOC_FORMAT_PRINTF(2, 3)
1312static bool

Callers 2

prof_dump_printfFunction · 0.70
prof_dump_mapsFunction · 0.70

Calls 1

prof_dump_flushFunction · 0.70

Tested by

no test coverage detected