]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fixes to prior checkins so that they compile and run even if SQLITE_MEMDEBUG malloc-enhancement
authordrh <drh@noemail.net>
Sun, 25 Jul 2010 02:39:06 +0000 (02:39 +0000)
committerdrh <drh@noemail.net>
Sun, 25 Jul 2010 02:39:06 +0000 (02:39 +0000)
is not defined.

FossilOrigin-Name: 548bf3f7d7b962d3eb0f5c874ecf40a8703d4d5d

manifest
manifest.uuid
src/malloc.c
src/mem2.c
src/sqliteInt.h

index d297456c3ae6a1f25a950885059f295545f7d299..e765e773c943b1b18d22791aa15e7fb6cfac10cd 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,8 +1,8 @@
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
-C Further\sexamples\sof\susing\sautomatic\sdeallocation\sto\sreplace\s"delete"\smethods.
-D 2010-07-25T02:12:51
+C Fixes\sto\sprior\scheckins\sso\sthat\sthey\scompile\sand\srun\seven\sif\sSQLITE_MEMDEBUG\nis\snot\sdefined.
+D 2010-07-25T02:39:07
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -139,10 +139,10 @@ F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f
 F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e
 F src/loadext.c 6d422ea91cf3d2d00408c5a8f2391cd458da85f8
 F src/main.c a487fe90aecaccb142e4a6b738c7e26e99145bcd
-F src/malloc.c a7e805ed0bd140b9b3110cee6fffe70b2361c7a3
+F src/malloc.c 2e38fd5e1539967cf4fa2d96edd82bd9d42183fd
 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
 F src/mem1.c 89d4ea8d5cdd55635cbaa48ad53132af6294cbb2
-F src/mem2.c 716e62689d49b01ee742be6c745b1c3bbfbccd18
+F src/mem2.c 47361e1235c5b74b4a269a62bcefda35a1fc91c4
 F src/mem3.c 9b237d911ba9904142a804be727cc6664873f8a3
 F src/mem5.c eb7a5cb98915dd7a086fa415ce3a5a0f20d0acff
 F src/memjournal.c 4a93a25ad9f76c40afa070ffd7187eb3a5fd7aee
@@ -175,7 +175,7 @@ F src/select.c b0fec59c8bb5246be793baa40b0518041837cc12
 F src/shell.c fd4ccdb37c3b68de0623eb938a649e0990710714
 F src/sqlite.h.in 2585fc82c922f2772e201e60a76d5fd1ca18370e
 F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89
-F src/sqliteInt.h 0431c9cd9a4158811d4c15dd362c3cae5ecb75da
+F src/sqliteInt.h 03ee6d40cf4139b040ab5c7ac6348db54bc78c08
 F src/sqliteLimit.h 196e2f83c3b444c4548fc1874f52f84fdbda40f3
 F src/status.c e2ad9f18c16209dab501e26020590fcebb2b751b
 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
@@ -841,14 +841,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P e5ecb15984e433b102e82eadb127d50ba2dc2ce3
-R a33d59e84cff2f0b84bd9d9458cba780
+P da2f62c502dfd3b53940b08a971137048732ecea
+R 0fe67466768edd87682f3d51d160d305
 U drh
-Z b0d2c45f9a50710478f7169e725e5290
+Z a683cf41c3a0308a70e3646adfaebebd
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.6 (GNU/Linux)
 
-iD8DBQFMS52moxKgR168RlERAidqAJ4wHohDl6Iox9qRr6lkRAJPtN4DEwCfUboT
-TLoFiPNTB9PUW0R9U0mj5LI=
-=EF4M
+iD8DBQFMS6PPoxKgR168RlERAgMpAJ0ZwfoWu2wFclx1N1sNN+VVUqK3QACgi2LD
+0zBS3EvSeICS3VbyxSU/aMM=
+=k4pP
 -----END PGP SIGNATURE-----
index aada8d3c94ef70c0211882288f453d43fcca1295..d141d68589d79a1dc5d1ca864703c0d93abfbca7 100644 (file)
@@ -1 +1 @@
-da2f62c502dfd3b53940b08a971137048732ecea
\ No newline at end of file
+548bf3f7d7b962d3eb0f5c874ecf40a8703d4d5d
\ No newline at end of file
index 90124c6775241856d7bc3ff96eb1e17f1784f3b9..8488cf9aa3e2fe377fb5ec3ee2c22782b95b0da1 100644 (file)
@@ -82,13 +82,15 @@ struct EMemHdr {
 # define setValidEMem(E)    (E)->iEMemMagic = 0xc0a43fad
 # define clearValidEMem(E)  (E)->iEMemMagic = 0x12345678
 # define isChildEMem(E)     ((E)->isAChild!=0)
+# define notChildEMem(E)    ((E)->isAChild==0)
 # define setChildEMem(E)    (E)->isAChild = 1
 # define clearChildEMem(E)  (E)->isAChild = 0
 #else
-# define isValidEMem(E)
+# define isValidEMem(E)     1
 # define setValidEMem(E)
 # define clearValidEMem(E)
-# define isChildEMem(E)
+# define isChildEMem(E)     1
+# define notChildEMem(E)    1
 # define setChildEMem(E)
 # define clearChildEMem(E)
 #endif
@@ -450,7 +452,7 @@ void sqlite3ScratchFree(void *p){
            || p<sqlite3GlobalConfig.pScratch
            || p>=(void*)mem0.aScratchFree ){
       assert( sqlite3MemdebugHasType(p, MEMTYPE_SCRATCH) );
-      assert( !sqlite3MemdebugHasType(p, ~MEMTYPE_SCRATCH) );
+      assert( sqlite3MemdebugNoType(p, ~MEMTYPE_SCRATCH) );
       sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
       if( sqlite3GlobalConfig.bMemstat ){
         int iSize = sqlite3MallocSize(p);
@@ -506,7 +508,7 @@ static int isLookaside(sqlite3 *db, void *p){
 */
 int sqlite3MallocSize(void *p){
   assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
-  assert( !sqlite3MemdebugHasType(p, MEMTYPE_RECURSIVE) );
+  assert( sqlite3MemdebugNoType(p, MEMTYPE_RECURSIVE) );
   return sqlite3GlobalConfig.m.xSize(p);
 }
 int sqlite3DbMallocSize(sqlite3 *db, void *pObj){
@@ -531,7 +533,7 @@ int sqlite3DbMallocSize(sqlite3 *db, void *pObj){
 */
 void sqlite3_free(void *p){
   if( p==0 ) return;
-  assert( !sqlite3MemdebugHasType(p, MEMTYPE_RECURSIVE) );
+  assert( sqlite3MemdebugNoType(p, MEMTYPE_RECURSIVE) );
   assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
   if( sqlite3GlobalConfig.bMemstat ){
     sqlite3_mutex_enter(mem0.mutex);
@@ -555,7 +557,7 @@ void sqlite3DbFree(sqlite3 *db, void *pObj){
   EMemHdr *p = (EMemHdr*)pObj;
   assert( db==0 || sqlite3_mutex_held(db->mutex) );
   if( p ) p--;
-  assert( p==0 || !isChildEMem(p) );  /* pObj is not child allocation */
+  assert( p==0 || notChildEMem(p) );  /* pObj is not child allocation */
   while( p ){
     EMemHdr *pNext = p->pESibling;
     assert( isValidEMem(p) );   /* pObj and all siblings are valid */
@@ -613,7 +615,7 @@ void *sqlite3Realloc(void *pOld, int nBytes){
       sqlite3MallocAlarm(nNew-nOld);
     }
     assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) );
-    assert( !sqlite3MemdebugHasType(pOld, ~MEMTYPE_HEAP) );
+    assert( sqlite3MemdebugNoType(pOld, ~MEMTYPE_HEAP) );
     pNew = sqlite3GlobalConfig.m.xRealloc(pOld, nNew);
     if( pNew==0 && mem0.alarmCallback ){
       sqlite3MallocAlarm(nBytes);
@@ -769,7 +771,7 @@ void *sqlite3DbRealloc(sqlite3 *db, void *pOld, int n){
     }
     p--;
     assert( isValidEMem(p) );    /* pOld obtained from extended allocator */
-    assert( !isChildEMem(p) );   /* pOld must not be a child allocation */
+    assert( notChildEMem(p) );   /* pOld must not be a child allocation */
     if( isLookaside(db, p) ){
       if( n+sizeof(EMemHdr)<=db->lookaside.sz ){
         return pOld;
@@ -859,7 +861,7 @@ void sqlite3MemLink(void *pParentObj, void *pChildObj){
     assert( isValidEMem(pParent) );  /* pParentObj is an extended allocation */ 
     pChild--;
     assert( isValidEMem(pChild) );   /* pChildObj is an extended allocation */
-    assert( !isChildEMem(pChild) );  /* pChildObj not a child of another obj */
+    assert( notChildEMem(pChild) );  /* pChildObj not a child of another obj */
     pChild->pESibling = pParent->pEChild;
     pParent->pEChild = pChild;
     setChildEMem(pChild);
index 587d9274e0d24f2e1b789dccb52d18eebb2eaec7..760e77ca2194bef6056eea450a2f560ccfc482e8 100644 (file)
@@ -408,6 +408,27 @@ int sqlite3MemdebugHasType(void *p, u8 eType){
   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.
index 923d232b9ea61891b85417b963cfcf8d7f62f71e..172c24f6a1056f15369657fb28d26b89e5d6e580 100644 (file)
@@ -3121,6 +3121,10 @@ 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.
+**
+** sqlite3MemdebugNoType() returns true if none of the bits in its second
+** argument match the type set by the previous sqlite3MemdebugSetType().
+**
 ** For example:
 **
 **     assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
@@ -3139,9 +3143,11 @@ 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 */