MCPcopy Create free account
hub / github.com/containers/bubblewrap / strappendf

Function strappendf

utils.c:1021–1047  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1019}
1020
1021__attribute__((format (printf, 2, 3)))
1022void
1023strappendf (StringBuilder *dest, const char *fmt, ...)
1024{
1025 va_list args;
1026 int len;
1027 size_t new_offset;
1028
1029 va_start (args, fmt);
1030 len = vsnprintf (dest->str + dest->offset, dest->size - dest->offset, fmt, args);
1031 va_end (args);
1032 if (len < 0)
1033 die_with_error ("vsnprintf");
1034 new_offset = xadd (dest->offset, len);
1035 if (new_offset >= dest->size)
1036 {
1037 dest->size = xmul (xadd (new_offset, 1), 2);
1038 dest->str = xrealloc (dest->str, dest->size);
1039 va_start (args, fmt);
1040 len = vsnprintf (dest->str + dest->offset, dest->size - dest->offset, fmt, args);
1041 va_end (args);
1042 if (len < 0)
1043 die_with_error ("vsnprintf");
1044 }
1045
1046 dest->offset = new_offset;
1047}
1048
1049void
1050strappend_escape_for_mount_options (StringBuilder *dest, const char *src)

Callers 2

setup_newrootFunction · 0.85
test_string_builderFunction · 0.85

Calls 4

die_with_errorFunction · 0.85
xaddFunction · 0.85
xmulFunction · 0.85
xreallocFunction · 0.85

Tested by 1

test_string_builderFunction · 0.68