From 742cc47bfbe67806f80bf4e821476b5efff9a9f6 Mon Sep 17 00:00:00 2001 From: Mel Date: Fri, 14 Mar 2025 16:43:08 +0100 Subject: Add compound literal casts to common functions (this isn't C++) Signed-off-by: Mel --- boot/common.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'boot/common.c') diff --git a/boot/common.c b/boot/common.c index 67e13eb..d43bbc1 100644 --- a/boot/common.c +++ b/boot/common.c @@ -100,12 +100,21 @@ string_new(const ascii* data, uint length) for (uint i = 0; i < length; ++i) at[i] = data[i]; at[length] = '\0'; - return { + return (struct String){ .data = at, .length = length, }; } +struct String +string_empty() +{ + return (struct String){ + .data = nil, + .length = 0, + }; +} + // allocates a new string in the global string region, // taking the data from a null-terminated C string. struct String @@ -124,7 +133,7 @@ struct String string_from_static_c_string(const char* c_string) { uint length = strlen(c_string); - return { + return (struct String){ .data = (ascii*)c_string, .length = length, }; -- cgit 1.4.1