最新版本的sqlite(3.7.10)想要链接__msize函数,既然Delphi内存管理器无法报告内存块的大小,我不得不介绍一个hack(d5兼容)
function __msize(p: pointer): Cardinal;cdecl; begin Result:=PInteger(integer(p)-4)^-6; end;
解决方法
在源代码的#15195行附近,注释以下行:
/* ** Windows systems have malloc_usable_size() but it is called _msize() */ #if !defined(HAVE_MALLOC_USABLE_SIZE) && sqlITE_OS_WIN # define HAVE_MALLOC_USABLE_SIZE 1 # define malloc_usable_size _msize #endif
成
/* ** Windows systems have malloc_usable_size() but it is called _msize() #if !defined(HAVE_MALLOC_USABLE_SIZE) && sqlITE_OS_WIN # define HAVE_MALLOC_USABLE_SIZE 1 # define malloc_usable_size _msize #endif */
它将禁用sqlite3 malloc的内存重用,并将依赖于更好的FastMM4 reallocmem()实现.
见this commit,例如我们的开源实现sqlite3静态链接.
附加信息:
我认为我们已经在3.7.11中解决了这个问题,如by this commit所述:将添加一个新的sqlITE_WITHOUT_MSIZE全局符号,并且只需设置适当的sqlITE_WITHOUT_MSIZE就可以构建合并源代码而无需更改其内容.限定.同时,最容易评论上述内容.