diff options
author | drh <drh@noemail.net> | 2010-07-26 11:07:20 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2010-07-26 11:07:20 +0000 |
commit | 174b9a166d293445dcc3075c292b78115b62be8f (patch) | |
tree | 1a5d8aeb2c14be45b0e4656208b0aec5815d5acf /src/sqliteInt.h | |
parent | d46def77db74a7dfadabb16da57c25d83af0c248 (diff) | |
parent | b975598ea0b3dbb1145513b0adada002c3c581bb (diff) | |
download | sqlite-174b9a166d293445dcc3075c292b78115b62be8f.tar.gz sqlite-174b9a166d293445dcc3075c292b78115b62be8f.zip |
Make sure all memory from sqlite3DbMalloc() is freed by sqlite3DbFree()
and all memory from sqlite3_malloc() is freed by sqlite3_free().
FossilOrigin-Name: 629e38a8c9e31111e351fe4625a5835576d23584
Diffstat (limited to 'src/sqliteInt.h')
-rw-r--r-- | src/sqliteInt.h | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 66f1cffb5..02705769c 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2327,7 +2327,7 @@ struct StrAccum { int nAlloc; /* Amount of space allocated in zText */ int mxAlloc; /* Maximum allowed string length */ u8 mallocFailed; /* Becomes true if any memory allocation fails */ - u8 useMalloc; /* True if zText is enlargeable using realloc */ + u8 useMalloc; /* 0: none, 1: sqlite3DbMalloc, 2: sqlite3_malloc */ u8 tooBig; /* Becomes true if string size exceeds limits */ }; @@ -3120,17 +3120,18 @@ SQLITE_EXTERN void (*sqlite3IoTrace)(const char*,...); ** sqlite3MemdebugHasType() returns true if any of the bits in its second ** argument match the type set by the previous sqlite3MemdebugSetType(). ** sqlite3MemdebugHasType() is intended for use inside assert() statements. -** For example: ** -** assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) ); +** sqlite3MemdebugNoType() returns true if none of the bits in its second +** argument match the type set by the previous sqlite3MemdebugSetType(). ** ** Perhaps the most important point is the difference between MEMTYPE_HEAP -** and MEMTYPE_DB. If an allocation is MEMTYPE_DB, that means it might have -** been allocated by lookaside, except the allocation was too large or -** lookaside was already full. It is important to verify that allocations -** that might have been satisfied by lookaside are not passed back to -** non-lookaside free() routines. Asserts such as the example above are -** placed on the non-lookaside free() routines to verify this constraint. +** and MEMTYPE_LOOKASIDE. If an allocation is MEMTYPE_LOOKASIDE, that means +** it might have been allocated by lookaside, except the allocation was +** too large or lookaside was already full. It is important to verify +** that allocations that might have been satisfied by lookaside are not +** passed back to non-lookaside free() routines. Asserts such as the +** example above are placed on the non-lookaside free() routines to verify +** this constraint. ** ** All of this is no-op for a production build. It only comes into ** play when the SQLITE_MEMDEBUG compile-time option is used. @@ -3138,13 +3139,16 @@ SQLITE_EXTERN void (*sqlite3IoTrace)(const char*,...); #ifdef SQLITE_MEMDEBUG void sqlite3MemdebugSetType(void*,u8); int sqlite3MemdebugHasType(void*,u8); + int sqlite3MemdebugNoType(void*,u8); #else # define sqlite3MemdebugSetType(X,Y) /* no-op */ # define sqlite3MemdebugHasType(X,Y) 1 +# define sqlite3MemdebugNoType(X,Y) 1 #endif -#define MEMTYPE_HEAP 0x01 /* General heap allocations */ -#define MEMTYPE_DB 0x02 /* Associated with a database connection */ -#define MEMTYPE_SCRATCH 0x04 /* Scratch allocations */ -#define MEMTYPE_PCACHE 0x08 /* Page cache allocations */ +#define MEMTYPE_HEAP 0x01 /* General heap allocations */ +#define MEMTYPE_LOOKASIDE 0x02 /* Might have been lookaside memory */ +#define MEMTYPE_SCRATCH 0x04 /* Scratch allocations */ +#define MEMTYPE_PCACHE 0x08 /* Page cache allocations */ +#define MEMTYPE_DB 0x10 /* Uses sqlite3DbMalloc, not sqlite_malloc */ #endif /* _SQLITEINT_H_ */ |