|
22 | 22 | #if defined(CBM_BIND_TS_ALLOCATOR) && CBM_BIND_TS_ALLOCATOR |
23 | 23 | #include "sqlite3.h" // sqlite3_mem_methods, sqlite3_config, SQLITE_CONFIG_MALLOC — bind sqlite to mimalloc |
24 | 24 | #if defined(HAVE_LIBGIT2) |
| 25 | +#include <git2/version.h> |
| 26 | +#if defined(LIBGIT2_VERSION_CHECK) |
| 27 | +#if !LIBGIT2_VERSION_CHECK(1, 7, 0) |
| 28 | +#error "HAVE_LIBGIT2 requires libgit2 >= 1.7.0 for git_allocator" |
| 29 | +#endif |
| 30 | +#elif defined(LIBGIT2_VER_MAJOR) && defined(LIBGIT2_VER_MINOR) && defined(LIBGIT2_VER_REVISION) |
| 31 | +#if ((LIBGIT2_VER_MAJOR * 1000000) + (LIBGIT2_VER_MINOR * 10000) + (LIBGIT2_VER_REVISION * 100)) < \ |
| 32 | + 1070000 |
| 33 | +#error "HAVE_LIBGIT2 requires libgit2 >= 1.7.0 for git_allocator" |
| 34 | +#endif |
| 35 | +#else |
| 36 | +#error "HAVE_LIBGIT2 requires known libgit2 version macros for the >= 1.7.0 git_allocator guard" |
| 37 | +#endif |
25 | 38 | #include <git2.h> // git_libgit2_opts, GIT_OPT_SET_ALLOCATOR — bind libgit2 to mimalloc |
26 | 39 | #include <git2/sys/alloc.h> // git_allocator — not pulled in by <git2.h> (it's a sys/ header) |
27 | 40 | #endif |
@@ -289,8 +302,8 @@ static void cbm_sqlite_memshutdown(void *appdata) { |
289 | 302 | } |
290 | 303 |
|
291 | 304 | #if defined(HAVE_LIBGIT2) |
292 | | -/* libgit2 git_allocator backed by mimalloc. The struct (current libgit2) has |
293 | | - * exactly three members: gmalloc(size_t,file,line), grealloc(ptr,size,file,line), |
| 305 | +/* libgit2 >= 1.7 git_allocator backed by mimalloc. The struct has exactly |
| 306 | + * three members: gmalloc(size_t,file,line), grealloc(ptr,size,file,line), |
294 | 307 | * gfree(ptr). The file/line args are ignored. */ |
295 | 308 | static void *cbm_git_malloc(size_t n, const char *file, int line) { |
296 | 309 | (void)file; |
|
0 commit comments