mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Fix join and concatenate to use the supplied allocator
This commit is contained in:
@@ -103,7 +103,7 @@ join :: proc(a: []string, sep: string, allocator := context.allocator) -> string
|
|||||||
n += len(s);
|
n += len(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
b := make([]byte, n);
|
b := make([]byte, n, allocator);
|
||||||
i := copy(b, cast([]byte)a[0]);
|
i := copy(b, cast([]byte)a[0]);
|
||||||
for s in a[1:] {
|
for s in a[1:] {
|
||||||
i += copy(b[i:], cast([]byte)sep);
|
i += copy(b[i:], cast([]byte)sep);
|
||||||
@@ -121,7 +121,7 @@ concatenate :: proc(a: []string, allocator := context.allocator) -> string {
|
|||||||
for s in a {
|
for s in a {
|
||||||
n += len(s);
|
n += len(s);
|
||||||
}
|
}
|
||||||
b := make([]byte, n);
|
b := make([]byte, n, allocator);
|
||||||
i := 0;
|
i := 0;
|
||||||
for s in a {
|
for s in a {
|
||||||
i += copy(b[i:], cast([]byte)s);
|
i += copy(b[i:], cast([]byte)s);
|
||||||
|
|||||||
Reference in New Issue
Block a user