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

Make sure all memory from sqlite3DbMalloc() is freed by sqlite3DbFree()

and all memory from sqlite3_malloc() is freed by sqlite3_free().

FossilOrigin-Name: 629e38a8c9e31111e351fe4625a5835576d23584
This commit is contained in:
drh
2010-07-26 11:07:20 +00:00
24 changed files with 183 additions and 142 deletions

View File

@@ -401,19 +401,34 @@ int sqlite3MemdebugHasType(void *p, u8 eType){
struct MemBlockHdr *pHdr;
pHdr = sqlite3MemsysGetHeader(p);
assert( pHdr->iForeGuard==FOREGUARD ); /* Allocation is valid */
assert( (pHdr->eType & (pHdr->eType-1))==0 ); /* Only one type bit set */
if( (pHdr->eType&eType)==0 ){
void **pBt;
pBt = (void**)pHdr;
pBt -= pHdr->nBacktraceSlots;
backtrace_symbols_fd(pBt, pHdr->nBacktrace, fileno(stderr));
fprintf(stderr, "\n");
rc = 0;
}
}
return rc;
}
/*
** Return TRUE if the mask of type in eType matches no bits of the type of the
** allocation p. Also return true if p==NULL.
**
** This routine is designed for use within an assert() statement, to
** verify the type of an allocation. For example:
**
** assert( sqlite3MemdebugNoType(p, MEMTYPE_DB) );
*/
int sqlite3MemdebugNoType(void *p, u8 eType){
int rc = 1;
if( p ){
struct MemBlockHdr *pHdr;
pHdr = sqlite3MemsysGetHeader(p);
assert( pHdr->iForeGuard==FOREGUARD ); /* Allocation is valid */
if( (pHdr->eType&eType)!=0 ){
rc = 0;
}
}
return rc;
}
/*
** Set the number of backtrace levels kept for each allocation.