From 5539d8a0881e28026eb070653d6b0f9b4976bbde Mon Sep 17 00:00:00 2001 From: krasimir Date: Wed, 18 May 2016 09:01:47 +0000 Subject: [PATCH] fix the compilation of sqlite3 on MacOS --- src/runtime/c/sg/sqlite3Btree.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/runtime/c/sg/sqlite3Btree.c b/src/runtime/c/sg/sqlite3Btree.c index 20d870918..f575c93ab 100644 --- a/src/runtime/c/sg/sqlite3Btree.c +++ b/src/runtime/c/sg/sqlite3Btree.c @@ -204,6 +204,7 @@ #include "sqlite3Btree.h" +#include #include /* Needed for the definition of va_list */ /* @@ -5172,6 +5173,7 @@ static SQLITE_WSD struct sqlite3StatType { #endif } sqlite3Stat = { {0,}, {0,} }; +#ifndef NDEBUG /* ** Elements of sqlite3Stat[] are protected by either the memory allocator ** mutex, or by the pcache1 mutex. The following array determines which. @@ -5188,7 +5190,7 @@ static const char statMutex[] = { 0, /* SQLITE_STATUS_SCRATCH_SIZE */ 0, /* SQLITE_STATUS_MALLOC_COUNT */ }; - +#endif /* The "wsdStat" macro will resolve to the status information ** state vector. If writable static data is unsupported on the target, @@ -7829,6 +7831,28 @@ SQLITE_PRIVATE void *sqlite3DbReallocOrFree(Btree *pBtree, void *p, u64 n){ return pNew; } +/* +** Make a copy of a string in memory obtained from sqliteMalloc(). These +** functions call sqlite3MallocRaw() directly instead of sqliteMalloc(). This +** is because when memory debugging is turned on, these two functions are +** called via macros that record the current file and line number in the +** ThreadData structure. +*/ +char *sqlite3DbStrDup(Btree *pBtree, const char *z){ + char *zNew; + size_t n; + if( z==0 ){ + return 0; + } + n = sqlite3Strlen30(z) + 1; + assert( (n&0x7fffffff)==n ); + zNew = sqlite3DbMallocRaw(pBtree, (int)n); + if( zNew ){ + memcpy(zNew, z, n); + } + return zNew; +} + /************** End of malloc.c **********************************************/ /************** Begin file printf.c ******************************************/ /*