mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
trim added null byte
This commit is contained in:
@@ -286,7 +286,7 @@ to_string :: proc(b: Builder) -> (res: string) {
|
|||||||
return string(b.buf[:])
|
return string(b.buf[:])
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Appends a trailing null byte if missing and then casts the Builder byte buffer to cstring
|
Appends a trailing null byte after the end of the current Builder byte buffer and then casts it to a cstring
|
||||||
|
|
||||||
Inputs:
|
Inputs:
|
||||||
- b: A pointer to builder
|
- b: A pointer to builder
|
||||||
@@ -295,21 +295,8 @@ Returns:
|
|||||||
- res: A cstring of the Builder's buffer
|
- res: A cstring of the Builder's buffer
|
||||||
*/
|
*/
|
||||||
to_cstring :: proc(b: ^Builder) -> (res: cstring) {
|
to_cstring :: proc(b: ^Builder) -> (res: cstring) {
|
||||||
if b.buf[len(b.buf)-1] != 0 {
|
append(&b.buf, 0)
|
||||||
append(&b.buf, 0)
|
defer pop(&p.buf)
|
||||||
}
|
|
||||||
return cstring(raw_data(b.buf))
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
Casts the Builder byte buffer to cstring, assuming it is already null-terminated
|
|
||||||
|
|
||||||
Inputs:
|
|
||||||
- b: A pointer to builder
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
- res: A cstring of the Builder's buffer
|
|
||||||
*/
|
|
||||||
to_cstring_unsafe :: proc(b: Builder) -> (res: cstring) {
|
|
||||||
return cstring(raw_data(b.buf))
|
return cstring(raw_data(b.buf))
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user