MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / snprintf0

Function snprintf0

util/str0.c:44–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42 */
43
44int snprintf0(char *buf, size_t bufsize, const char *fmt, ...)
45{
46 int rc;
47 va_list ap;
48
49 if (buf == NULL || bufsize == 0) {
50 logmsg(LOGMSG_ERROR, "snprintf0(%d): ERROR: bad buffer @%p(%zu)\n",
51 (int)getpid(), buf, bufsize);
52 return -1;
53 }
54
55 if (fmt == NULL) {
56 logmsg(LOGMSG_ERROR, "snprintf0(%d): ERROR: NULL format\n", (int)getpid());
57 return -1;
58 }
59
60 va_start(ap, fmt);
61 rc = vsnprintf(buf, bufsize, fmt, ap);
62 va_end(ap);
63 buf[bufsize - 1] = '\0';
64 return rc;
65}
66
67/** Safe version of strcpy(), more reliable than strncpy().
68 *

Callers 15

fstdump_threadFunction · 0.85
fstdump_thread_innerFunction · 0.85
write_recordsFunction · 0.85
close_retryFunction · 0.85
get_retryFunction · 0.85
open_retryFunction · 0.85
form_queuedb_name_intFunction · 0.85
mainFunction · 0.85
rewrite_lrl_tableFunction · 0.85
osql_bplog_time_doneFunction · 0.85

Calls 1

logmsgFunction · 0.70

Tested by

no test coverage detected