ds: uuid: convert uuid bytes struct to union
This commit is contained in:
14
ds/uuid.c
14
ds/uuid.c
@@ -9,7 +9,7 @@
|
||||
/*** PRIVATE DATA *************************************************************/
|
||||
|
||||
struct b_uuid_p {
|
||||
struct b_uuid_bytes uuid_bytes;
|
||||
union b_uuid_bytes uuid_bytes;
|
||||
};
|
||||
|
||||
/*** PRIVATE FUNCTIONS ********************************************************/
|
||||
@@ -39,12 +39,12 @@ static void uuid_get_bytes(
|
||||
}
|
||||
|
||||
static void uuid_get_uuid_bytes(
|
||||
const struct b_uuid_p *uuid, struct b_uuid_bytes *bytes)
|
||||
const struct b_uuid_p *uuid, union b_uuid_bytes *bytes)
|
||||
{
|
||||
memcpy(bytes, &uuid->uuid_bytes, sizeof *bytes);
|
||||
}
|
||||
|
||||
static struct b_uuid_bytes *uuid_ptr(struct b_uuid_p *uuid)
|
||||
static union b_uuid_bytes *uuid_ptr(struct b_uuid_p *uuid)
|
||||
{
|
||||
return &uuid->uuid_bytes;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ b_uuid *b_uuid_create_from_bytev(const unsigned char bytes[B_UUID_NBYTES])
|
||||
|
||||
b_uuid *b_uuid_create_from_cstr(const char *str)
|
||||
{
|
||||
struct b_uuid_bytes bytes;
|
||||
union b_uuid_bytes bytes;
|
||||
|
||||
bool valid = true;
|
||||
bool is_guid = false;
|
||||
@@ -169,19 +169,19 @@ void b_uuid_get_bytes(const b_uuid *uuid, unsigned char bytes[B_UUID_NBYTES])
|
||||
B_CLASS_DISPATCH_STATIC(B_TYPE_UUID, uuid_get_bytes, uuid, bytes);
|
||||
}
|
||||
|
||||
void b_uuid_get_uuid_bytes(const b_uuid *uuid, struct b_uuid_bytes *bytes)
|
||||
void b_uuid_get_uuid_bytes(const b_uuid *uuid, union b_uuid_bytes *bytes)
|
||||
{
|
||||
B_CLASS_DISPATCH_STATIC(B_TYPE_UUID, uuid_get_uuid_bytes, uuid, bytes);
|
||||
}
|
||||
|
||||
struct b_uuid_bytes *b_uuid_ptr(b_uuid *uuid)
|
||||
union b_uuid_bytes *b_uuid_ptr(b_uuid *uuid)
|
||||
{
|
||||
B_CLASS_DISPATCH_STATIC_0(B_TYPE_UUID, uuid_ptr, uuid);
|
||||
}
|
||||
|
||||
/*** PUBLIC ALIAS FUNCTIONS ***************************************************/
|
||||
|
||||
b_uuid *b_uuid_create_from_uuid_bytes(const struct b_uuid_bytes *bytes)
|
||||
b_uuid *b_uuid_create_from_uuid_bytes(const union b_uuid_bytes *bytes)
|
||||
{
|
||||
return b_uuid_create_from_bytev(bytes->uuid_bytes);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user