Merge pull request #212 from gwsystems/module-database-only

refactor: module db capacity
main
Sean McBride 4 years ago committed by GitHub
commit 01019aa968
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,7 +23,6 @@
#define MODULE_MAX_ARGUMENT_COUNT 16 #define MODULE_MAX_ARGUMENT_COUNT 16
#define MODULE_MAX_ARGUMENT_SIZE 64 #define MODULE_MAX_ARGUMENT_SIZE 64
#define MODULE_MAX_MODULE_COUNT 128
#define MODULE_MAX_NAME_LENGTH 32 #define MODULE_MAX_NAME_LENGTH 32
#define MODULE_MAX_PATH_LENGTH 256 #define MODULE_MAX_PATH_LENGTH 256

@ -2,6 +2,8 @@
#include "module.h" #include "module.h"
#define MODULE_DATABASE_CAPACITY 128
int module_database_add(struct module *module); int module_database_add(struct module *module);
struct module *module_database_find_by_name(char *name); struct module *module_database_find_by_name(char *name);
struct module *module_database_find_by_socket_descriptor(int socket_descriptor); struct module *module_database_find_by_socket_descriptor(int socket_descriptor);

@ -7,8 +7,8 @@
* Module Database * * Module Database *
******************/ ******************/
struct module *module_database[MODULE_MAX_MODULE_COUNT] = { NULL }; struct module *module_database[MODULE_DATABASE_CAPACITY] = { NULL };
size_t module_database_count = 0; size_t module_database_count = 0;
/** /**
* Adds a module to the in-memory module DB * Adds a module to the in-memory module DB
@ -18,11 +18,11 @@ size_t module_database_count = 0;
int int
module_database_add(struct module *module) module_database_add(struct module *module)
{ {
assert(module_database_count <= MODULE_MAX_MODULE_COUNT); assert(module_database_count <= MODULE_DATABASE_CAPACITY);
int rc; 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; module_database[module_database_count++] = module;
rc = 0; rc = 0;

Loading…
Cancel
Save