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

Function strappend

utils.c:1002–1019  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1000}
1001
1002void
1003strappend (StringBuilder *dest, const char *src)
1004{
1005 size_t len = strlen (src);
1006 size_t new_offset = xadd (dest->offset, len);
1007
1008 if (new_offset >= dest->size)
1009 {
1010 dest->size = xmul (xadd (new_offset, 1), 2);
1011 dest->str = xrealloc (dest->str, dest->size);
1012 }
1013
1014 /* Preserves the invariant that dest->str is always null-terminated, even
1015 * though the offset is positioned at the null byte for the next write.
1016 */
1017 strncpy (dest->str + dest->offset, src, len + 1);
1018 dest->offset = new_offset;
1019}
1020
1021__attribute__((format (printf, 2, 3)))
1022void

Callers 2

setup_newrootFunction · 0.85
test_string_builderFunction · 0.85

Calls 3

xaddFunction · 0.85
xmulFunction · 0.85
xreallocFunction · 0.85

Tested by 1

test_string_builderFunction · 0.68