Commit 6554b40e by Edward Thomson

settings: localize global data

Move the settings global data teardown into its own separate function,
instead of intermingled with the global state.
parent 521aa8c1
......@@ -11,6 +11,7 @@
#include "hash.h"
#include "sysdir.h"
#include "filter.h"
#include "settings.h"
#include "merge_driver.h"
#include "pool.h"
#include "streams/registry.h"
......@@ -37,15 +38,14 @@ static git_global_init_fn git__init_callbacks[] = {
git_openssl_stream_global_init,
git_mbedtls_stream_global_init,
git_mwindow_global_init,
git_pool_global_init
git_pool_global_init,
git_settings_global_init
};
static git_global_shutdown_fn git__shutdown_callbacks[ARRAY_SIZE(git__init_callbacks)];
static git_atomic git__n_shutdown_callbacks;
static git_atomic git__n_inits;
char *git__user_agent;
char *git__ssl_ciphers;
void git__on_shutdown(git_global_shutdown_fn callback)
{
......@@ -93,9 +93,6 @@ static void shutdown_common(void)
if (cb != NULL)
cb();
}
git__free(git__user_agent);
git__free(git__ssl_ciphers);
}
/**
......
......@@ -35,7 +35,4 @@ typedef void (*git_global_shutdown_fn)(void);
extern void git__on_shutdown(git_global_shutdown_fn callback);
extern const char *git_libgit2__user_agent(void);
extern const char *git_libgit2__ssl_ciphers(void);
#endif
......@@ -29,6 +29,28 @@
#include "streams/openssl.h"
#include "streams/mbedtls.h"
/* Declarations for tuneable settings */
extern size_t git_mwindow__window_size;
extern size_t git_mwindow__mapped_limit;
extern size_t git_mwindow__file_limit;
extern size_t git_indexer__max_objects;
extern bool git_disable_pack_keep_file_checks;
char *git__user_agent;
char *git__ssl_ciphers;
static void git_settings_global_shutdown(void)
{
git__free(git__user_agent);
git__free(git__ssl_ciphers);
}
int git_settings_global_init(void)
{
git__on_shutdown(git_settings_global_shutdown);
return 0;
}
int git_libgit2_version(int *major, int *minor, int *rev)
{
*major = LIBGIT2_VER_MAJOR;
......@@ -56,13 +78,6 @@ int git_libgit2_features(void)
;
}
/* Declarations for tuneable settings */
extern size_t git_mwindow__window_size;
extern size_t git_mwindow__mapped_limit;
extern size_t git_mwindow__file_limit;
extern size_t git_indexer__max_objects;
extern bool git_disable_pack_keep_file_checks;
static int config_level_to_sysdir(int config_level)
{
int val = -1;
......@@ -88,9 +103,6 @@ static int config_level_to_sysdir(int config_level)
return val;
}
extern char *git__user_agent;
extern char *git__ssl_ciphers;
const char *git_libgit2__user_agent(void)
{
return git__user_agent;
......
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
extern int git_settings_global_init(void);
extern const char *git_libgit2__user_agent(void);
extern const char *git_libgit2__ssl_ciphers(void);
......@@ -12,6 +12,7 @@
#include <ctype.h>
#include "global.h"
#include "settings.h"
#include "posix.h"
#include "stream.h"
#include "streams/socket.h"
......
......@@ -9,6 +9,7 @@
#define INCLUDE_transports_http_h__
#include "buffer.h"
#include "settings.h"
#include "httpclient.h"
#define GIT_HTTP_REPLAY_MAX 15
......
#include "clar_libgit2.h"
#include "global.h"
#include "settings.h"
void test_core_useragent__get(void)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment