]> git.ipfire.org Git - pakfire.git/commitdiff
arch: Fix convoluted way to find supported arches
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Aug 2023 16:27:09 +0000 (16:27 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Aug 2023 16:27:09 +0000 (16:27 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/arch.c

index 7cf6ee438a35f386f78eb073a9ea689b00fb4d59..5fb8420560eb70d9d5fd6e5e8404d05ecb96e63a 100644 (file)
@@ -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) {