summaryrefslogtreecommitdiff
path: root/src/cli/global.c
blob: b509d6bf7320679854b88d0682eb4139e5cf767e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
 * 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.
 */

#include <stdio.h>
#include <git2.h>
#include <git2client.h>
#include "git2_util.h"
#include "cli.h"
#include "hash.h"
#include "runtime.h"

#ifdef GIT_WIN32
# include "win32/w32_crtdbg_stacktrace.h"
# include "win32/w32_stack.h"
#endif

static void client_shutdown(void);

static int client_init(void)
{
	if (git_client_init() < 0)
		return -1;

	return git_runtime_shutdown_register(client_shutdown);
}

static void client_shutdown(void)
{
	git_client_shutdown();
}

int cli_global_init()
{
	static git_runtime_init_fn init_fns[] = {
		client_init,

#if defined(GIT_MSVC_CRTDBG)
		git_win32__crtdbg_stacktrace_init,
		git_win32__stack_init,
#endif
		git_allocator_global_init,
		git_hash_global_init,
		git_threads_global_init,
		git_ssh_subtransport_register
	};

	return git_runtime_init(init_fns, ARRAY_SIZE(init_fns));
}

int cli_global_shutdown()
{
	return git_runtime_shutdown();
}