MCPcopy Create free account
hub / github.com/F-Stack/f-stack / safe_itoa

Function safe_itoa

dpdk/lib/eal/unix/eal_debug.c:21–37  ·  view source on GitHub ↗

* Convert number to string and return start of string. * Note: string does not start at beginning of buffer. */

Source from the content-addressed store, hash-verified

19 * Note: string does not start at beginning of buffer.
20 */
21static char *safe_itoa(long val, char *buf, size_t len, unsigned int radix)
22{
23 char *bp = buf + len;
24 static const char hexdigit[] = "0123456789abcdef";
25
26 *--bp = '\0'; /* Null terminate the string */
27 do {
28 /* if buffer is not big enough, then truncate */
29 if (bp == buf)
30 return bp;
31
32 *--bp = hexdigit[val % radix];
33 val /= radix;
34 } while (val != 0);
35
36 return bp;
37}
38
39/*
40 * Dump the stack of the calling core

Callers 1

rte_dump_stackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected