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

Add extra assert() statements trying to catch a Mem object in an inconsistent

state.

FossilOrigin-Name: 4aeb3ae435c78070232fef21a147fde4e1c5cd31
This commit is contained in:
drh
2014-03-01 14:45:18 +00:00
parent efbf3b1a10
commit defbd9dade
6 changed files with 38 additions and 16 deletions

View File

@@ -232,6 +232,24 @@ struct Mem {
#define memIsValid(M) ((M)->flags & MEM_Undefined)==0
#endif
/*
** A sanity check on a Mem object and especially the Mem.z field.
** This check says that no more than one of the following may be true:
** (1) Mem.z comes from Mem.zMalloc
** (2) Mem.z has a destructor Mem.xDel
** (3) Mem.z is an ephemeral string
** (4) Mem.z is a static string
**
** Use only inside of an assert() as follows: assert( memSanify(pMem) );
*/
#ifdef SQLITE_DEBUG
#define memSanity1(p) \
((((p)->zMalloc && (p)->zMalloc==(p)->z) ? 1 : 0) + \
((((p)->flags&MEM_Dyn)&&(p)->xDel) ? 1 : 0) + \
(((p)->flags&MEM_Ephem) ? 1 : 0) + \
(((p)->flags&MEM_Static) ? 1 : 0) <= 1 )
#endif
/*
** Each auxilliary data pointer stored by a user defined function
** implementation calling sqlite3_set_auxdata() is stored in an instance