mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 16:44:36 +00:00
Update uuid.cpp
2 pass format_token, 1st gets the length required second passes it to target.
This commit is contained in:
parent
3e57c709d9
commit
0853748f12
1 changed files with 8 additions and 1 deletions
|
|
@ -146,7 +146,14 @@ static void create_uuid_state(uuid_state *st)
|
||||||
*/
|
*/
|
||||||
static void format_token(char *target, const xuuid_t *u)
|
static void format_token(char *target, const xuuid_t *u)
|
||||||
{
|
{
|
||||||
snprintf(target, strlen(target), "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
// first loop, figure out the size needed.
|
||||||
|
size_t len = (size_t)snprintf(NULL, 0, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||||
|
u->time_low, u->time_mid, u->time_hi_and_version,
|
||||||
|
u->clock_seq_hi_and_reserved, u->clock_seq_low,
|
||||||
|
u->node[0], u->node[1], u->node[2],
|
||||||
|
u->node[3], u->node[4], u->node[5]);
|
||||||
|
|
||||||
|
snprintf(target, len+1, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||||
u->time_low, u->time_mid, u->time_hi_and_version,
|
u->time_low, u->time_mid, u->time_hi_and_version,
|
||||||
u->clock_seq_hi_and_reserved, u->clock_seq_low,
|
u->clock_seq_hi_and_reserved, u->clock_seq_low,
|
||||||
u->node[0], u->node[1], u->node[2],
|
u->node[0], u->node[1], u->node[2],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue