From df1c1000014049d95d65de831f9015a2dcf9fa34 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Mon, 11 Nov 2024 14:02:45 -0800 Subject: treewide: Make carray arrays const and NULL-terminated This allows the compiler to generate significantly better code, because it does not have to maintain either the loop counter or loop limit. Plus there are half as many symbols to relocate. This also simplifies passing carray arrays to helper functions. Signed-off-by: Samuel Holland Reviewed-by: Anup Patel --- scripts/carray.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/carray.sh b/scripts/carray.sh index 1fa2366a..72808697 100755 --- a/scripts/carray.sh +++ b/scripts/carray.sh @@ -69,10 +69,9 @@ for VAR in ${VAR_LIST}; do done printf "\n" -printf "%s *%s[] = {\n" "${TYPE_NAME}" "${ARRAY_NAME}" +printf "%s *const %s[] = {\n" "${TYPE_NAME}" "${ARRAY_NAME}" for VAR in ${VAR_LIST}; do printf "\t&%s,\n" "${VAR}" done -printf "};\n\n" - -printf "unsigned long %s_size = sizeof(%s) / sizeof(%s *);\n" "${ARRAY_NAME}" "${ARRAY_NAME}" "${TYPE_NAME}" + printf "\tNULL\n" +printf "};\n" -- cgit v1.3.1