From e42a04b2ce9bea9cb2031258475896df0f12250f Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Wed, 5 May 2021 15:10:51 +0000 Subject: [PATCH] refactor: module db capacity --- runtime/include/module.h | 1 - runtime/include/module_database.h | 2 ++ runtime/src/module_database.c | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/runtime/include/module.h b/runtime/include/module.h index 69c7ee7..e366be7 100644 --- a/runtime/include/module.h +++ b/runtime/include/module.h @@ -23,7 +23,6 @@ #define MODULE_MAX_ARGUMENT_COUNT 16 #define MODULE_MAX_ARGUMENT_SIZE 64 -#define MODULE_MAX_MODULE_COUNT 128 #define MODULE_MAX_NAME_LENGTH 32 #define MODULE_MAX_PATH_LENGTH 256 diff --git a/runtime/include/module_database.h b/runtime/include/module_database.h index 7b61345..8d8c40e 100644 --- a/runtime/include/module_database.h +++ b/runtime/include/module_database.h @@ -2,6 +2,8 @@ #include "module.h" +#define MODULE_DATABASE_CAPACITY 128 + int module_database_add(struct module *module); struct module *module_database_find_by_name(char *name); struct module *module_database_find_by_socket_descriptor(int socket_descriptor); diff --git a/runtime/src/module_database.c b/runtime/src/module_database.c index d3daa00..e4ebd15 100644 --- a/runtime/src/module_database.c +++ b/runtime/src/module_database.c @@ -7,8 +7,8 @@ * Module Database * ******************/ -struct module *module_database[MODULE_MAX_MODULE_COUNT] = { NULL }; -size_t module_database_count = 0; +struct module *module_database[MODULE_DATABASE_CAPACITY] = { NULL }; +size_t module_database_count = 0; /** * Adds a module to the in-memory module DB @@ -18,11 +18,11 @@ size_t module_database_count = 0; int module_database_add(struct module *module) { - assert(module_database_count <= MODULE_MAX_MODULE_COUNT); + assert(module_database_count <= MODULE_DATABASE_CAPACITY); int rc; - if (module_database_count == MODULE_MAX_MODULE_COUNT) goto err_no_space; + if (module_database_count == MODULE_DATABASE_CAPACITY) goto err_no_space; module_database[module_database_count++] = module; rc = 0;