From 5be0e2a890eca355dc8a1ba5d761e404bd7d7bf7 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 18 Aug 2023 16:27:09 +0000 Subject: [PATCH] arch: Fix convoluted way to find supported arches Signed-off-by: Michael Tremer --- src/libpakfire/arch.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/libpakfire/arch.c b/src/libpakfire/arch.c index 7cf6ee438..5fb842056 100644 --- a/src/libpakfire/arch.c +++ b/src/libpakfire/arch.c @@ -90,29 +90,22 @@ PAKFIRE_EXPORT int pakfire_arch_supported(const char* name) { return 0; } -const char** __pakfire_supported_arches = NULL; - PAKFIRE_EXPORT const char** pakfire_supported_arches() { - unsigned int counter = 0; - - if (!__pakfire_supported_arches) { - for (const struct pakfire_arch* arch = PAKFIRE_ARCHES; arch->name; arch++) { - __pakfire_supported_arches = reallocarray(__pakfire_supported_arches, - counter + 2, sizeof(*__pakfire_supported_arches)); + static const char* supported_arches[] = { + // x86_64 + PAKFIRE_ARCHES[0].name, - // Exit if the allocation failed - if (!__pakfire_supported_arches) - return NULL; + // aarch64 + PAKFIRE_ARCHES[1].name, - __pakfire_supported_arches[counter++] = arch->name; - } + // riscv64 + PAKFIRE_ARCHES[2].name, // Sentinel - if (__pakfire_supported_arches) - __pakfire_supported_arches[counter] = NULL; - } + NULL, + }; - return __pakfire_supported_arches; + return supported_arches; } const char* pakfire_arch_platform(const char* name) { -- 2.39.5