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

Function malloc_vsnprintf

deps/jemalloc/src/malloc_io.c:326–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324}
325
326size_t
327malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
328 size_t i;
329 const char *f;
330
331#define APPEND_C(c) do { \
332 if (i < size) { \
333 str[i] = (c); \
334 } \
335 i++; \
336} while (0)
337#define APPEND_S(s, slen) do { \
338 if (i < size) { \
339 size_t cpylen = (slen <= size - i) ? slen : size - i; \
340 memcpy(&str[i], s, cpylen); \
341 } \
342 i += slen; \
343} while (0)
344#define APPEND_PADDED_S(s, slen, width, left_justify) do { \
345 /* Left padding. */ \
346 size_t pad_len = (width == -1) ? 0 : ((slen < (size_t)width) ? \
347 (size_t)width - slen : 0); \
348 if (!left_justify && pad_len != 0) { \
349 size_t j; \
350 for (j = 0; j < pad_len; j++) { \
351 APPEND_C(' '); \
352 } \
353 } \
354 /* Value. */ \
355 APPEND_S(s, slen); \
356 /* Right padding. */ \
357 if (left_justify && pad_len != 0) { \
358 size_t j; \
359 for (j = 0; j < pad_len; j++) { \
360 APPEND_C(' '); \
361 } \
362 } \
363} while (0)
364#define GET_ARG_NUMERIC(val, len) do { \
365 switch ((unsigned char)len) { \
366 case '?': \

Callers 5

safety_check_failFunction · 0.70
prof_dump_printfFunction · 0.70
prof_open_mapsFunction · 0.70
malloc_io.cFile · 0.70
log_impl_varargsFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected