mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
[fmt] Add allocator parameter to fmt.aprintf
This allows you to do `fmt.aprintf("Hello, %v!", name, allocator = ally)`.
This commit is contained in:
+2
-2
@@ -152,9 +152,9 @@ aprintln :: proc(args: ..any, sep := " ") -> string {
|
|||||||
//
|
//
|
||||||
// Returns: A formatted string. The returned string must be freed accordingly.
|
// Returns: A formatted string. The returned string must be freed accordingly.
|
||||||
//
|
//
|
||||||
aprintf :: proc(fmt: string, args: ..any) -> string {
|
aprintf :: proc(fmt: string, args: ..any, allocator := context.allocator) -> string {
|
||||||
str: strings.Builder
|
str: strings.Builder
|
||||||
strings.builder_init(&str)
|
strings.builder_init(&str, allocator)
|
||||||
sbprintf(&str, fmt, ..args)
|
sbprintf(&str, fmt, ..args)
|
||||||
return strings.to_string(str)
|
return strings.to_string(str)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user