mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-09 14:21:03 +03:00
Added an assert() to detect lookaside memory leaks. Also added the
SQLITE_OMIT_LOOKASIDE compile-time option which is useful in trying to track down lookaside memory leaks. (CVS 5800) FossilOrigin-Name: 0c4c66071a46cecc5f87afb8f8f01ae2c90ee9b3
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
**
|
||||
** Memory allocation functions used throughout sqlite.
|
||||
**
|
||||
** $Id: malloc.c,v 1.42 2008/09/23 16:41:30 danielk1977 Exp $
|
||||
** $Id: malloc.c,v 1.43 2008/10/11 15:38:30 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <stdarg.h>
|
||||
@@ -485,9 +485,13 @@ void sqlite3PageFree(void *p){
|
||||
/*
|
||||
** TRUE if p is a lookaside memory allocation from db
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_LOOKASIDE
|
||||
static int isLookaside(sqlite3 *db, void *p){
|
||||
return db && p && p>=db->lookaside.pStart && p<db->lookaside.pEnd;
|
||||
}
|
||||
#else
|
||||
#define isLookaside(A,B) 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Return the size of a memory allocation previously obtained from
|
||||
@@ -617,6 +621,7 @@ void *sqlite3DbMallocZero(sqlite3 *db, int n){
|
||||
*/
|
||||
void *sqlite3DbMallocRaw(sqlite3 *db, int n){
|
||||
void *p;
|
||||
#ifndef SQLITE_OMIT_LOOKASIDE
|
||||
if( db ){
|
||||
LookasideSlot *pBuf;
|
||||
if( db->mallocFailed ){
|
||||
@@ -632,6 +637,7 @@ void *sqlite3DbMallocRaw(sqlite3 *db, int n){
|
||||
return (void*)pBuf;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
p = sqlite3Malloc(n);
|
||||
if( !p && db ){
|
||||
db->mallocFailed = 1;
|
||||
|
||||
Reference in New Issue
Block a user