Skip to content

Commit

Permalink
Mention how to initialize the library in the samples
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosmn committed Oct 19, 2015
1 parent 36e379b commit b75d548
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/guides/101-samples/index.md
Expand Up @@ -6,6 +6,28 @@ layout: toc

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

<h3 id="best_practices_init">Initialize the library</h3>

The library needs to keep some global state and initialize its
dependencies. You must therefore initialize the library before working
with it

```C
git_libgit2_init();
```

Usually you don't need to call the shutdown function as the operating
system will take care of reclaiming resources, but if your application
uses libgit2 in some areas which are not usually active, you can use

```C
git_libgit2_shutdown();
```

to ask the library to clean up the global state. The cleanup will be
performed once there have been the same number of calls to
`git_libgit2_shutdown()` as there were for `git_libgit2_init()`.

<h3 id="best_practices_errors">Errors</h3>

Return codes from public APIs indicate general failure category.
Expand Down

0 comments on commit b75d548

Please sign in to comment.