From b75d548171fd50e2afaec88e9c8492814ea62ad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 19 Oct 2015 16:45:15 +0200 Subject: [PATCH] Mention how to initialize the library in the samples --- docs/guides/101-samples/index.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/guides/101-samples/index.md b/docs/guides/101-samples/index.md index 0035c3a..509b2e4 100644 --- a/docs/guides/101-samples/index.md +++ b/docs/guides/101-samples/index.md @@ -6,6 +6,28 @@ layout: toc

Best Practices

+

Initialize the library

+ +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()`. +

Errors

Return codes from public APIs indicate general failure category.