}
#if !defined(KERNEL)
-void
+int
opr_uuid_toString(const opr_uuid_t *uuid, char **string)
{
unsigned const char *p;
+ int r;
p = uuid->data;
- asprintf(string,
- "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-"
- "%02x%02x%02x%02x%02x%02x",
- p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],
- p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
+ r = asprintf(string,
+ "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-"
+ "%02x%02x%02x%02x%02x%02x",
+ p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],
+ p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
+ if (r < 0) {
+ *string = NULL;
+ return ENOMEM;
+ }
+ return 0;
}
void