Re: linking libgit.a in C++ projects
- From
Dmitry Potapov <dpotapov@gmail.com>
- Date
- Jul 31, 2008, 14:44 UTC
- Message-ID
- <20080731144424.GH7008@dpotapov.dyndns.org>
- In-Reply-To
- <4891B872.3040707@panasas.com>
On Thu, Jul 31, 2008 at 04:04:50PM +0300, Boaz Harrosh wrote:
Show 6 quoted lines
> > Produce a C file and header that defines some stable API to your > GUI application, that does not expose any git internal headers. > Then compile that, say git_api.c, with C compiler in Makefile > and extern "C" link that file to your C++ application. This will > completely insulate you from any git code.
While the idea of creating of such a wrapper makes sense, it may not easy to implement properly in all cases, because some git functions do not free allocated memory as they rely on this memory being free at exit. There is a problem with die() as it is not enough to longjmp from it, you have to free all resources that were allocated (such as open files, memory). Thus writing a full functional library, which will not leak resources, is not an easy task. Of course, some of Git function can be used easily without risk that your application will leak resources.
Dmitry