提交 993374d8 编写于 作者: xpxyr's avatar xpxyr 提交者: geniusgogo

add rtt memory management support

上级 bb718508
......@@ -75,10 +75,27 @@ static malloc_zone_t* _sqliteZone_;
#define SQLITE_MALLOCSIZE(x) \
(_sqliteZone_ ? _sqliteZone_->size(_sqliteZone_,x) : malloc_size(x))
#elif defined(SQLITE_OS_RTT)
/*
** Use standard C library malloc and free on non-Apple systems.
** Also used by rt-thread systems if SQLITE_WITHOUT_ZONEMALLOC is defined.
*/
#define SQLITE_MALLOC(x) rt_malloc(x)
#define SQLITE_FREE(x) rt_free(x)
#define SQLITE_REALLOC(x,y) rt_realloc((x),(y))
#if (!defined(SQLITE_WITHOUT_MSIZE)) \
&& (defined(HAVE_MALLOC_H) && defined(HAVE_MALLOC_USABLE_SIZE))
# error "not have malloc_usable_size()"
#endif
#ifdef HAVE_MALLOC_USABLE_SIZE
# undef SQLITE_MALLOCSIZE
#endif
#else /* if not __APPLE__ */
/*
** Use standard C library malloc and free on non-Apple systems.
** Use standard C library malloc and free on non-Apple systems.
** Also used by Apple systems if SQLITE_WITHOUT_ZONEMALLOC is defined.
*/
#define SQLITE_MALLOC(x) malloc(x)
......@@ -229,13 +246,13 @@ static int sqlite3MemInit(void *NotUsed){
/* defer MT decisions to system malloc */
_sqliteZone_ = malloc_default_zone();
}else{
/* only 1 core, use our own zone to contention over global locks,
/* only 1 core, use our own zone to contention over global locks,
** e.g. we have our own dedicated locks */
bool success;
malloc_zone_t* newzone = malloc_create_zone(4096, 0);
malloc_set_zone_name(newzone, "Sqlite_Heap");
do{
success = OSAtomicCompareAndSwapPtrBarrier(NULL, newzone,
success = OSAtomicCompareAndSwapPtrBarrier(NULL, newzone,
(void * volatile *)&_sqliteZone_);
}while(!_sqliteZone_);
if( !success ){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册