MCPcopy Index your code
hub / github.com/expr-lang/expr / printHexPtr

Function printHexPtr

internal/spew/common.go:185–215  ·  view source on GitHub ↗

printHexPtr outputs a uintptr formatted as hexadecimal with a leading '0x' prefix to Writer w.

(w io.Writer, p uintptr)

Source from the content-addressed store, hash-verified

183// printHexPtr outputs a uintptr formatted as hexadecimal with a leading '0x'
184// prefix to Writer w.
185func printHexPtr(w io.Writer, p uintptr) {
186 // Null pointer.
187 num := uint64(p)
188 if num == 0 {
189 w.Write(nilAngleBytes)
190 return
191 }
192
193 // Max uint64 is 16 bytes in hex + 2 bytes for '0x' prefix
194 buf := make([]byte, 18)
195
196 // It's simpler to construct the hex string right to left.
197 base := uint64(16)
198 i := len(buf) - 1
199 for num >= base {
200 buf[i] = hexDigits[num%base]
201 num /= base
202 i--
203 }
204 buf[i] = hexDigits[num]
205
206 // Add '0x' prefix.
207 i--
208 buf[i] = 'x'
209 i--
210 buf[i] = '0'
211
212 // Strip unused leading bytes.
213 buf = buf[i:]
214 w.Write(buf)
215}
216
217// valuesSorter implements sort.Interface to allow a slice of reflect.Value
218// elements to be sorted.

Callers 4

formatPtrMethod · 0.85
formatMethod · 0.85
dumpPtrMethod · 0.85
dumpMethod · 0.85

Calls 1

WriteMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…