Skip to content

Commit b75d548

Browse files
committed
Mention how to initialize the library in the samples
1 parent 36e379b commit b75d548

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

docs/guides/101-samples/index.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,28 @@ layout: toc
66

77
<h2 id="best_practices">Best Practices</h2>
88

9+
<h3 id="best_practices_init">Initialize the library</h3>
10+
11+
The library needs to keep some global state and initialize its
12+
dependencies. You must therefore initialize the library before working
13+
with it
14+
15+
```C
16+
git_libgit2_init();
17+
```
18+
19+
Usually you don't need to call the shutdown function as the operating
20+
system will take care of reclaiming resources, but if your application
21+
uses libgit2 in some areas which are not usually active, you can use
22+
23+
```C
24+
git_libgit2_shutdown();
25+
```
26+
27+
to ask the library to clean up the global state. The cleanup will be
28+
performed once there have been the same number of calls to
29+
`git_libgit2_shutdown()` as there were for `git_libgit2_init()`.
30+
931
<h3 id="best_practices_errors">Errors</h3>
1032

1133
Return codes from public APIs indicate general failure category.

0 commit comments

Comments
 (0)