changes global variable to static

This commit is contained in:
2026-06-28 21:52:49 -05:00
parent 43813ba0a4
commit 9badfb3040
2 changed files with 19 additions and 19 deletions

View File

@@ -46,14 +46,14 @@ struct callback_struct
} }
callback_type; callback_type;
static struct global_log_data_struct static struct static_log_data_struct
{ {
void *user_data; void *user_data;
lock_function lock; lock_function lock;
int severity_level; int severity_level;
bool quiet; bool quiet;
callback_type callbacks[MAX_CALLBACKS]; callback_type callbacks[MAX_CALLBACKS];
} global_log_data_struct; } static_log_data_struct;
static const char * static const char *
@@ -147,10 +147,10 @@ file_callback(log_event_type *event)
static void static void
lock(void) lock(void)
{ {
if (global_log_data_struct.lock) if (static_log_data_struct.lock)
{ {
global_log_data_struct.lock(true, static_log_data_struct.lock(true,
global_log_data_struct.user_data); static_log_data_struct.user_data);
} }
} }
@@ -158,10 +158,10 @@ lock(void)
static void static void
unlock(void) unlock(void)
{ {
if (global_log_data_struct.lock) if (static_log_data_struct.lock)
{ {
global_log_data_struct.lock(false, static_log_data_struct.lock(false,
global_log_data_struct.user_data); static_log_data_struct.user_data);
} }
} }
@@ -177,22 +177,22 @@ void
log_set_lock(lock_function function, log_set_lock(lock_function function,
void *user_data) void *user_data)
{ {
global_log_data_struct.lock = function; static_log_data_struct.lock = function;
global_log_data_struct.user_data = user_data; static_log_data_struct.user_data = user_data;
} }
void void
log_set_level(int severity_level) log_set_level(int severity_level)
{ {
global_log_data_struct.severity_level = severity_level; static_log_data_struct.severity_level = severity_level;
} }
void void
log_set_quiet(bool should_be_quiet) log_set_quiet(bool should_be_quiet)
{ {
global_log_data_struct.quiet = should_be_quiet; static_log_data_struct.quiet = should_be_quiet;
} }
@@ -203,12 +203,12 @@ log_add_callback(log_function function,
{ {
for (int i = 0; i < MAX_CALLBACKS; i++) for (int i = 0; i < MAX_CALLBACKS; i++)
{ {
if (global_log_data_struct.callbacks[i].function) if (static_log_data_struct.callbacks[i].function)
{ {
continue; continue;
} }
global_log_data_struct.callbacks[i] = (callback_type) static_log_data_struct.callbacks[i] = (callback_type)
{ {
function, function,
user_data, user_data,
@@ -260,8 +260,8 @@ log_log(int severity_level,
lock(); lock();
if (!global_log_data_struct.quiet if (!static_log_data_struct.quiet
&& severity_level >= global_log_data_struct.severity_level) && severity_level >= static_log_data_struct.severity_level)
{ {
init_event(&event, init_event(&event,
stderr); stderr);
@@ -274,10 +274,10 @@ log_log(int severity_level,
} }
for (int i = 0; i < MAX_CALLBACKS for (int i = 0; i < MAX_CALLBACKS
&& global_log_data_struct.callbacks[i].function; && static_log_data_struct.callbacks[i].function;
i++) i++)
{ {
callback_type *callback_pointer = &global_log_data_struct.callbacks[i]; callback_type *callback_pointer = &static_log_data_struct.callbacks[i];
if (severity_level >= callback_pointer->severity_level) if (severity_level >= callback_pointer->severity_level)
{ {
init_event(&event, init_event(&event,

View File

@@ -16,7 +16,7 @@
#include <stdbool.h> #include <stdbool.h>
#include <time.h> #include <time.h>
#define LOG_VERSION "r:180.26.1" #define LOG_VERSION "r:2.26.180.1"
typedef typedef
struct log_event_struct struct log_event_struct