mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
Merge pull request #4152 from edyu/master
Fix error for uuid to require 36 bytes instead 32 (4 bytes for dashes)
This commit is contained in:
@@ -11,7 +11,7 @@ Write a UUID in the 8-4-4-4-12 format.
|
||||
This procedure performs error checking with every byte written.
|
||||
|
||||
If you can guarantee beforehand that your stream has enough space to hold the
|
||||
UUID (32 bytes), then it is better to use `unsafe_write` instead as that will
|
||||
UUID (36 bytes), then it is better to use `unsafe_write` instead as that will
|
||||
be faster.
|
||||
|
||||
Inputs:
|
||||
@@ -106,7 +106,7 @@ Convert a UUID to a string in the 8-4-4-4-12 format.
|
||||
|
||||
Inputs:
|
||||
- id: The identifier to convert.
|
||||
- buffer: A byte buffer to store the result. Must be at least 32 bytes large.
|
||||
- buffer: A byte buffer to store the result. Must be at least 36 bytes large.
|
||||
- loc: The caller location for debugging purposes (default: #caller_location)
|
||||
|
||||
Returns:
|
||||
@@ -119,7 +119,11 @@ to_string_buffer :: proc(
|
||||
) -> (
|
||||
str: string,
|
||||
) {
|
||||
assert(len(buffer) >= EXPECTED_LENGTH, "The buffer provided is not at least 32 bytes large.", loc)
|
||||
assert(
|
||||
len(buffer) >= EXPECTED_LENGTH,
|
||||
"The buffer provided is not at least 36 bytes large.",
|
||||
loc,
|
||||
)
|
||||
builder := strings.builder_from_bytes(buffer)
|
||||
unsafe_write(strings.to_writer(&builder), id)
|
||||
return strings.to_string(builder)
|
||||
@@ -129,3 +133,4 @@ to_string :: proc {
|
||||
to_string_allocated,
|
||||
to_string_buffer,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user