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