MCPcopy
hub / github.com/tinylib/msgp / ensure

Function ensure

msgp/write_bytes.go:13–22  ·  view source on GitHub ↗

ensure 'sz' extra bytes in 'b' btw len(b) and cap(b)

(b []byte, sz int)

Source from the content-addressed store, hash-verified

11
12// ensure 'sz' extra bytes in 'b' btw len(b) and cap(b)
13func ensure(b []byte, sz int) ([]byte, int) {
14 l := len(b)
15 c := cap(b)
16 if c-l < sz {
17 o := make([]byte, (2*c)+sz) // exponential growth
18 n := copy(o, b)
19 return o[:n+sz], n
20 }
21 return b[:l+sz], l
22}
23
24// AppendMapHeader appends a map header with the
25// given size to the slice

Callers 15

AppendExtensionFunction · 0.70
AppendMapHeaderFunction · 0.70
AppendArrayHeaderFunction · 0.70
AppendFloat64Function · 0.70
AppendFloat32Function · 0.70
AppendInt64Function · 0.70
AppendUint64Function · 0.70
AppendBytesFunction · 0.70
AppendBytesHeaderFunction · 0.70
AppendStringFunction · 0.70
AppendStringFromBytesFunction · 0.70
AppendComplex64Function · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…