From 0cf9c22033a28283feecbd8f9d4cc0720be7d5b4 Mon Sep 17 00:00:00 2001 From: Pix Date: Tue, 15 Aug 2023 12:30:40 +0800 Subject: [PATCH] Builder makes added caller location --- core/strings/builder.odin | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/core/strings/builder.odin b/core/strings/builder.odin index 28c56f6f9..d87626d07 100644 --- a/core/strings/builder.odin +++ b/core/strings/builder.odin @@ -35,8 +35,8 @@ Returns: - res: The new Builder - err: An optional allocator error if one occured, `nil` otherwise */ -builder_make_none :: proc(allocator := context.allocator) -> (res: Builder, err: mem.Allocator_Error) #optional_allocator_error { - return Builder{buf=make([dynamic]byte, allocator) or_return }, nil +builder_make_none :: proc(allocator := context.allocator, loc := #caller_location) -> (res: Builder, err: mem.Allocator_Error) #optional_allocator_error { + return Builder{buf=make([dynamic]byte, allocator, loc) or_return }, nil } /* Produces a Builder with a specified length and cap of max(16,len) byte buffer @@ -51,8 +51,8 @@ Returns: - res: The new Builder - err: An optional allocator error if one occured, `nil` otherwise */ -builder_make_len :: proc(len: int, allocator := context.allocator) -> (res: Builder, err: mem.Allocator_Error) #optional_allocator_error { - return Builder{buf=make([dynamic]byte, len, allocator) or_return }, nil +builder_make_len :: proc(len: int, allocator := context.allocator, loc := #caller_location) -> (res: Builder, err: mem.Allocator_Error) #optional_allocator_error { + return Builder{buf=make([dynamic]byte, len, allocator, loc) or_return }, nil } /* Produces a Builder with a specified length and cap @@ -68,8 +68,8 @@ Returns: - res: The new Builder - err: An optional allocator error if one occured, `nil` otherwise */ -builder_make_len_cap :: proc(len, cap: int, allocator := context.allocator) -> (res: Builder, err: mem.Allocator_Error) #optional_allocator_error { - return Builder{buf=make([dynamic]byte, len, cap, allocator) or_return }, nil +builder_make_len_cap :: proc(len, cap: int, allocator := context.allocator, loc := #caller_location) -> (res: Builder, err: mem.Allocator_Error) #optional_allocator_error { + return Builder{buf=make([dynamic]byte, len, cap, allocator, loc) or_return }, nil } /* Produces a String Builder @@ -116,8 +116,8 @@ Returns: - res: A pointer to the initialized Builder - err: An optional allocator error if one occured, `nil` otherwise */ -builder_init_none :: proc(b: ^Builder, allocator := context.allocator) -> (res: ^Builder, err: mem.Allocator_Error) #optional_allocator_error { - b.buf = make([dynamic]byte, allocator) or_return +builder_init_none :: proc(b: ^Builder, allocator := context.allocator, loc := #caller_location) -> (res: ^Builder, err: mem.Allocator_Error) #optional_allocator_error { + b.buf = make([dynamic]byte, allocator, loc) or_return return b, nil } /* @@ -135,8 +135,8 @@ Returns: - res: A pointer to the initialized Builder - err: An optional allocator error if one occured, `nil` otherwise */ -builder_init_len :: proc(b: ^Builder, len: int, allocator := context.allocator) -> (res: ^Builder, err: mem.Allocator_Error) #optional_allocator_error { - b.buf = make([dynamic]byte, len, allocator) or_return +builder_init_len :: proc(b: ^Builder, len: int, allocator := context.allocator, loc := #caller_location) -> (res: ^Builder, err: mem.Allocator_Error) #optional_allocator_error { + b.buf = make([dynamic]byte, len, allocator, loc) or_return return b, nil } /* @@ -153,8 +153,8 @@ Returns: - res: A pointer to the initialized Builder - err: An optional allocator error if one occured, `nil` otherwise */ -builder_init_len_cap :: proc(b: ^Builder, len, cap: int, allocator := context.allocator) -> (res: ^Builder, err: mem.Allocator_Error) #optional_allocator_error { - b.buf = make([dynamic]byte, len, cap, allocator) or_return +builder_init_len_cap :: proc(b: ^Builder, len, cap: int, allocator := context.allocator, loc := #caller_location) -> (res: ^Builder, err: mem.Allocator_Error) #optional_allocator_error { + b.buf = make([dynamic]byte, len, cap, allocator, loc) or_return return b, nil } // Overload simple `builder_init_*` with or without len / ap parameters