MCPcopy Create free account
hub / github.com/coreboot/coreboot / bintohex

Function bintohex

util/cbfstool/common.c:205–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205char *bintohex(uint8_t *data, size_t len)
206{
207 static const char __nonstring translate[16] = "0123456789abcdef";
208
209 char *result = malloc(len * 2 + 1);
210 if (result == NULL)
211 return NULL;
212
213 result[len*2] = '\0';
214 unsigned int i;
215 for (i = 0; i < len; i++) {
216 result[i*2] = translate[(data[i] >> 4) & 0xf];
217 result[i*2+1] = translate[data[i] & 0xf];
218 }
219 return result;
220}

Callers 4

update_and_infoFunction · 0.85
cbfs_printFunction · 0.85
cbfs_print_entry_infoFunction · 0.85

Calls 1

mallocFunction · 0.50

Tested by

no test coverage detected