From: Michael Tremer Date: Fri, 18 Aug 2023 16:27:09 +0000 (+0000) Subject: arch: Fix convoluted way to find supported arches X-Git-Tag: 0.9.29~71 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5be0e2a890eca355dc8a1ba5d761e404bd7d7bf7;p=pakfire.git arch: Fix convoluted way to find supported arches Signed-off-by: Michael Tremer --- 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) {