Temporary allocator for context

This commit is contained in:
gingerBill
2018-08-29 19:55:55 +01:00
parent 28523f17e2
commit 001837e6bb
7 changed files with 145 additions and 14 deletions
+18
View File
@@ -159,6 +159,24 @@ aprintf :: proc(fmt: string, args: ..any) -> string {
}
// tprint* procedures return a string that was allocated with the current context's temporary allocator
tprint :: proc(args: ..any) -> string {
buf := String_Buffer(make([dynamic]byte, context.temp_allocator));
sbprint(&buf, ..args);
return to_string(buf);
}
tprintln :: proc(args: ..any) -> string {
buf := String_Buffer(make([dynamic]byte, context.temp_allocator));
sbprintln(&buf, ..args);
return to_string(buf);
}
tprintf :: proc(fmt: string, args: ..any) -> string {
buf := String_Buffer(make([dynamic]byte, context.temp_allocator));
sbprintf(&buf, fmt, ..args);
return to_string(buf);
}
// bprint* procedures return a string using a buffer from an array
bprint :: proc(buf: []byte, args: ..any) -> string {
sb := string_buffer_from_slice(buf[0:len(buf)]);