1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-09 14:21:03 +03:00

Continuing progress on the new memory allocation subsystem. Added the

sqlite3_mem_methods structure for defining new memory allocators at
run-time. (CVS 5219)

FossilOrigin-Name: f00305f4cd2f487f660f34a21c1c24a0b37c7275
This commit is contained in:
drh
2008-06-14 16:56:21 +00:00
parent 40257ffd0a
commit fec00eabb3
10 changed files with 559 additions and 447 deletions

View File

@@ -19,7 +19,7 @@
** implementation is suitable for testing.
** debugging purposes
**
** $Id: mutex.c,v 1.18 2008/06/13 18:24:27 drh Exp $
** $Id: mutex.c,v 1.19 2008/06/14 16:56:23 drh Exp $
*/
#include "sqliteInt.h"
@@ -77,7 +77,7 @@ sqlite3_mutex *sqlite3_mutex_alloc(int id){
** This routine deallocates a previously allocated mutex.
*/
void sqlite3_mutex_free(sqlite3_mutex *p){
assert( p );
if( p==0 ) return;
assert( p->cnt==0 );
assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE );
sqlite3_free(p);
@@ -95,14 +95,16 @@ void sqlite3_mutex_free(sqlite3_mutex *p){
** more than once, the behavior is undefined.
*/
void sqlite3_mutex_enter(sqlite3_mutex *p){
assert( p );
assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(p) );
p->cnt++;
if( p ){
assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(p) );
p->cnt++;
}
}
int sqlite3_mutex_try(sqlite3_mutex *p){
assert( p );
assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(p) );
p->cnt++;
if( p ){
assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(p) );
p->cnt++;
}
return SQLITE_OK;
}
@@ -113,10 +115,11 @@ int sqlite3_mutex_try(sqlite3_mutex *p){
** is not currently allocated. SQLite will never do either.
*/
void sqlite3_mutex_leave(sqlite3_mutex *p){
assert( p );
assert( sqlite3_mutex_held(p) );
p->cnt--;
assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(p) );
if( p ){
assert( sqlite3_mutex_held(p) );
p->cnt--;
assert( p->id==SQLITE_MUTEX_RECURSIVE || sqlite3_mutex_notheld(p) );
}
}
/*