From cb0c1663b77022c90d8d645a62e47184399ea46b Mon Sep 17 00:00:00 2001 From: Bazzagibbs Date: Mon, 11 Nov 2024 14:04:59 +1100 Subject: Add core:slice.size to get the byte size of a slice's backing data --- core/slice/slice.odin | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/slice/slice.odin b/core/slice/slice.odin index cd12a8c70..c31edf281 100644 --- a/core/slice/slice.odin +++ b/core/slice/slice.odin @@ -471,6 +471,12 @@ is_empty :: proc(a: $T/[]$E) -> bool { return len(a) == 0 } +// Gets the byte size of the backing data +@(require_results) +size :: proc "contextless" (a: $T/[]$E) -> int { + return len(a) * size_of(E) +} + @(require_results) -- cgit v1.2.3