return 0;
}
+static size_t pakfire_num_arches(void) {
+ size_t i = 0;
+
+ for (const struct pakfire_arch* arch = PAKFIRE_ARCHES; arch->name; arch++)
+ i++;
+
+ return i;
+}
+
PAKFIRE_EXPORT const char** pakfire_supported_arches(void) {
- static const char* supported_arches[] = {
- // x86_64
- PAKFIRE_ARCHES[0].name,
+ const struct pakfire_arch* arch = NULL;
+ static const char** arches = NULL;
- // aarch64
- PAKFIRE_ARCHES[1].name,
+ if (!arches) {
+ // Count how many architectures we have
+ const size_t num_arches = pakfire_num_arches();
+ unsigned int i = 0;
- // riscv64
- PAKFIRE_ARCHES[2].name,
+ // Allocate a new array
+ arches = calloc(num_arches + 1, sizeof(*arches));
+ if (!arches)
+ return NULL;
- // Sentinel
- NULL,
- };
+ // Copy all architectures
+ for (arch = PAKFIRE_ARCHES; arch->name; arch++)
+ arches[i++] = arch->name;
+ }
- return supported_arches;
+ return arches;
}
const char* pakfire_arch_platform(const char* name) {