MCPcopy Index your code
hub / github.com/docker/docker-agent / cloneMessage

Function cloneMessage

pkg/session/session.go:428–432  ·  view source on GitHub ↗

cloneMessage returns a deep copy of a session Message. It copies the inner chat.Message's slice and pointer fields so that the returned value shares no mutable state with the original.

(m *Message)

Source from the content-addressed store, hash-verified

426// It copies the inner chat.Message's slice and pointer fields so that the
427// returned value shares no mutable state with the original.
428func cloneMessage(m *Message) *Message {
429 cp := *m
430 cp.Message = cloneChatMessage(m.Message)
431 return &cp
432}
433
434// snapshotItems returns a copy of s.Messages safe to use without holding
435// s.mu. Each Message value is deep-copied so concurrent UpdateMessage calls

Callers 5

CloneMethod · 0.85
cloneSessionItemFunction · 0.85
AddMessageMethod · 0.85
UpdateMessageMethod · 0.85
snapshotItemsMethod · 0.85

Calls 1

cloneChatMessageFunction · 0.85

Tested by

no test coverage detected