From: drh Date: Tue, 31 Aug 2010 15:27:32 +0000 (+0000) Subject: Add evidence mark comments to source code. Add additional information to the X-Git-Tag: experimental~94 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9f129f467e7961b3225a0ecc37d26cddc9155943;p=thirdparty%2Fsqlite.git Add evidence mark comments to source code. Add additional information to the documentation of sqlite3_release_memory(). Fix a minor inefficiency in mem1.c that was discovered while writing requirements tests. FossilOrigin-Name: 53b0c03fd33d2d8141fd386de5493fec64456042 --- diff --git a/manifest b/manifest index f890fe1330..f5ec2ed0d7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,8 @@ -C Add\sthe\s"circle"\stest\sgeometry\scallback\sto\stest_rtree.c.\sAnd\stests\sfor\sthe\ssame. -D 2010-08-31T15:02:01 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +C Add\sevidence\smark\scomments\sto\ssource\scode.\s\sAdd\sadditional\sinformation\sto\sthe\ndocumentation\sof\ssqlite3_release_memory().\s\sFix\sa\sminor\sinefficiency\sin\smem1.c\nthat\swas\sdiscovered\swhile\swriting\srequirements\stests. +D 2010-08-31T15:27:32 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in c599a15d268b1db2aeadea19df2adc3bf2eb6bee F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -113,7 +116,7 @@ F src/alter.c 8dc27638e7e2553e80b2b621f232be5eb1e85ef3 F src/analyze.c da65ce99bb159b10e85a1e460adbe53a88062500 F src/attach.c c689d516ee8cc52bf11bef2067d76eb8b716228a F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 -F src/backup.c 8ff0b7018df253c7f30d3f9702b0b16f19209d5c +F src/backup.c d5b0137bc20327af08c14772227cc35134839c30 F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 96a12f50f7a17475155971a241d85ec5171573ff F src/btree.c 175495bf9a377a5526c82450dc2ce069a974e61c @@ -138,13 +141,13 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 7f026423f4d71d989e719a743f98a1cbd4e6d99e F src/loadext.c 6d422ea91cf3d2d00408c5a8f2391cd458da85f8 -F src/main.c 66ea03499db1add96bcd20f38fdd04599d2a54db -F src/malloc.c f34c9253326fcd2dad0041801992ccf18ddd6ab5 +F src/main.c 4965866d307ecb99f2830ae98ec50520551ad293 +F src/malloc.c d9fcf07f366a29d45d4c3157323074578912b83c F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 -F src/mem1.c 89d4ea8d5cdd55635cbaa48ad53132af6294cbb2 -F src/mem2.c 9e5f72e38573db9598fe60d3fa530d473cc8714e +F src/mem1.c 00bd8265c81abb665c48fea1e0c234eb3b922206 +F src/mem2.c e307323e86b5da1853d7111b68fd6b84ad6f09cf F src/mem3.c 9b237d911ba9904142a804be727cc6664873f8a3 -F src/mem5.c eb7a5cb98915dd7a086fa415ce3a5a0f20d0acff +F src/mem5.c 6fe00f46997bebb690397cb029719f711e7640e3 F src/memjournal.c 4a93a25ad9f76c40afa070ffd7187eb3a5fd7aee F src/mutex.c 6949180803ff05a7d0e2b9334a95b4fb5a00e23f F src/mutex.h 6fde601e55fa6c3fae768783c439797ab84c87c6 @@ -173,7 +176,7 @@ F src/resolve.c 1c0f32b64f8e3f555fe1f732f9d6f501a7f05706 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697 F src/select.c fb7008115d9ccd85f6b6934c15c204b7fe6bfc38 F src/shell.c 8517fc1f9c59ae4007e6cc8b9af91ab231ea2056 -F src/sqlite.h.in 55498e6664eecf9a1db722d473445dbd210fe5f7 +F src/sqlite.h.in c5776806401dcd4afe026925b3dcceb4cb249217 F src/sqlite3ext.h 69dfb8116af51b84a029cddb3b35062354270c89 F src/sqliteInt.h 4e31d3b58720d6251e08ba394641b9a63725eb8a F src/sqliteLimit.h a17dcd3fb775d63b64a43a55c54cb282f9726f44 @@ -220,12 +223,12 @@ F src/tokenize.c 604607d6813e9551cf5189d899e0a25c12681080 F src/trigger.c b8bedb9c0084ceb51a40f54fcca2ce048c8de852 F src/update.c 227e6cd512108b84f69421fc6c7aa1b83d60d6e0 F src/utf.c 1baeeac91707a4df97ccc6141ec0f808278af685 -F src/util.c 32aebf04c10e51ad3977a928b7416bed671b620b +F src/util.c 5f5f4db4e799224713582bb49124827b16aa8e54 F src/vacuum.c 241a8386727c1497eba4955933356dfba6ff8c9f F src/vdbe.c 36d9521bfc257bc068ad0bdee8f341d96d858ff7 F src/vdbe.h 4de0efb4b0fdaaa900cf419b35c458933ef1c6d2 F src/vdbeInt.h a247bd5448039e83394bf4179975b2ae0092874c -F src/vdbeapi.c d0f4407e465f261780ad725c1caece7d66a6aa35 +F src/vdbeapi.c bec07756e1b3ec5cd054ce8d32a80787763fd07e F src/vdbeaux.c de0b06b11a25293e820a49159eca9f1c51a64716 F src/vdbeblob.c 258a6010ba7a82b72b327fb24c55790655689256 F src/vdbemem.c e5673f81a2381b35c60e73ef0a8502be2ab1041e @@ -851,7 +854,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P 86bcb9aab901713684f978479d29304cc9699e84 -R 5c25e19d785d39dcca465a202d21adcc -U dan -Z 0dfc99dba1561d16d8cd1c933b53fac9 +P 169b8ba4be9c3941c742eded80dbacdcd2465bc4 +R 3d17e398a58367e277a246a8a180d51e +U drh +Z b41028ed1baa7e42a13b3d1df82c72ac +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.6 (GNU/Linux) + +iD8DBQFMfR9noxKgR168RlERAjqyAJ4lX1R/JatXzxXtHhQhCw4qI7EyQwCffGzX +cWyqfe9/7iMLgUrcwtZ+UDQ= +=vS4Z +-----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 46510b5cb4..011e3b7dac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -169b8ba4be9c3941c742eded80dbacdcd2465bc4 \ No newline at end of file +53b0c03fd33d2d8141fd386de5493fec64456042 \ No newline at end of file diff --git a/src/backup.c b/src/backup.c index 1fc01e1add..db8baeac5e 100644 --- a/src/backup.c +++ b/src/backup.c @@ -150,7 +150,10 @@ sqlite3_backup *sqlite3_backup_init( ); p = 0; }else { - /* Allocate space for a new sqlite3_backup object */ + /* Allocate space for a new sqlite3_backup object... + ** EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a + ** call to sqlite3_backup_init() and is destroyed by a call to + ** sqlite3_backup_finish(). */ p = (sqlite3_backup *)sqlite3_malloc(sizeof(sqlite3_backup)); if( !p ){ sqlite3Error(pDestDb, SQLITE_NOMEM, 0); @@ -533,6 +536,9 @@ int sqlite3_backup_finish(sqlite3_backup *p){ } sqlite3BtreeLeave(p->pSrc); if( p->pDestDb ){ + /* EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a + ** call to sqlite3_backup_init() and is destroyed by a call to + ** sqlite3_backup_finish(). */ sqlite3_free(p); } sqlite3_mutex_leave(mutex); diff --git a/src/main.c b/src/main.c index 7ddd66a7fe..e1b69f6f17 100644 --- a/src/main.c +++ b/src/main.c @@ -26,15 +26,33 @@ # include "sqliteicu.h" #endif -/* -** The version of the library -*/ #ifndef SQLITE_AMALGAMATION +/* IMPLEMENTATION-OF: R-46656-45156 The sqlite3_version[] string constant +** contains the text of SQLITE_VERSION macro. +*/ const char sqlite3_version[] = SQLITE_VERSION; #endif + +/* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns +** a pointer to the to the sqlite3_version[] string constant. +*/ const char *sqlite3_libversion(void){ return sqlite3_version; } + +/* IMPLEMENTATION-OF: R-63124-39300 The sqlite3_sourceid() function returns a +** pointer to a string constant whose value is the same as the +** SQLITE_SOURCE_ID C preprocessor macro. +*/ const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; } + +/* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function +** returns an integer equal to SQLITE_VERSION_NUMBER. +*/ int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; } + +/* IMPLEMENTATION-OF: R-54823-41343 The sqlite3_threadsafe() function returns +** zero if and only if SQLite was compiled mutexing code omitted due to +** the SQLITE_THREADSAFE compile-time option being set to 0. +*/ int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; } #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE) diff --git a/src/malloc.c b/src/malloc.c index 0b19cff8b7..ac1910389b 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -62,12 +62,13 @@ void sqlite3_soft_heap_limit(int n){ */ int sqlite3_release_memory(int n){ #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT - int nRet = 0; - nRet += sqlite3PcacheReleaseMemory(n-nRet); - return nRet; + return sqlite3PcacheReleaseMemory(n); #else + /* IMPLEMENTATION-OF: R-34391-24921 The sqlite3_release_memory() routine + ** is a no-op returning zero if SQLite is not compiled with + ** SQLITE_ENABLE_MEMORY_MANAGEMENT. */ UNUSED_PARAMETER(n); - return SQLITE_OK; + return 0; #endif } @@ -511,6 +512,9 @@ void *sqlite3Realloc(void *pOld, int nBytes){ return 0; } nOld = sqlite3MallocSize(pOld); + /* IMPLEMENTATION-OF: R-46199-30249 SQLite guarantees that the second + ** argument to xRealloc is always a value returned by a prior call to + ** xRoundup. */ nNew = sqlite3GlobalConfig.m.xRoundup(nBytes); if( nOld==nNew ){ pNew = pOld; diff --git a/src/mem1.c b/src/mem1.c index 1a01839992..61fbf4bdba 100644 --- a/src/mem1.c +++ b/src/mem1.c @@ -89,7 +89,7 @@ static int sqlite3MemSize(void *pPrior){ static void *sqlite3MemRealloc(void *pPrior, int nByte){ sqlite3_int64 *p = (sqlite3_int64*)pPrior; assert( pPrior!=0 && nByte>0 ); - nByte = ROUND8(nByte); + assert( nByte==ROUND8(nByte) ); /* EV: R-46199-30249 */ p--; p = realloc(p, nByte+8 ); if( p ){ diff --git a/src/mem2.c b/src/mem2.c index 83f12fdb11..26448ea8aa 100644 --- a/src/mem2.c +++ b/src/mem2.c @@ -344,6 +344,7 @@ static void *sqlite3MemRealloc(void *pPrior, int nByte){ struct MemBlockHdr *pOldHdr; void *pNew; assert( mem.disallow==0 ); + assert( (nByte & 7)==0 ); /* EV: R-46199-30249 */ pOldHdr = sqlite3MemsysGetHeader(pPrior); pNew = sqlite3MemMalloc(nByte); if( pNew ){ diff --git a/src/mem5.c b/src/mem5.c index a828cf812e..2fdfac1413 100644 --- a/src/mem5.c +++ b/src/mem5.c @@ -395,7 +395,7 @@ static void *memsys5Realloc(void *pPrior, int nBytes){ int nOld; void *p; assert( pPrior!=0 ); - assert( (nBytes&(nBytes-1))==0 ); + assert( (nBytes&(nBytes-1))==0 ); /* EV: R-46199-30249 */ assert( nBytes>=0 ); if( nBytes==0 ){ return 0; diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 6fdadb6955..1139b98c42 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -4089,6 +4089,8 @@ int sqlite3_enable_shared_cache(int); ** pages to improve performance is an example of non-essential memory. ** ^sqlite3_release_memory() returns the number of bytes actually freed, ** which might be more or less than the amount requested. +** ^The sqlite3_release_memory() routine is a no-op returning zero +** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT]. */ int sqlite3_release_memory(int); diff --git a/src/util.c b/src/util.c index ab31424ed6..6b30b311ae 100644 --- a/src/util.c +++ b/src/util.c @@ -215,6 +215,12 @@ int sqlite3Dequote(char *z){ /* ** Some systems have stricmp(). Others have strcasecmp(). Because ** there is no consistency, we will define our own. +** +** IMPLEMENTATION-OF: R-20522-24639 The sqlite3_strnicmp() API allows +** applications and extensions to compare the contents of two buffers +** containing UTF-8 strings in a case-independent fashion, using the same +** definition of case independence that SQLite uses internally when +** comparing identifiers. */ int sqlite3StrICmp(const char *zLeft, const char *zRight){ register unsigned char *a, *b; diff --git a/src/vdbeapi.c b/src/vdbeapi.c index afb4a1b6e6..256828e807 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -495,6 +495,12 @@ void *sqlite3_user_data(sqlite3_context *p){ /* ** Extract the user data from a sqlite3_context structure and return a ** pointer to it. +** +** IMPLEMENTATION-OF: R-46798-50301 The sqlite3_context_db_handle() interface +** returns a copy of the pointer to the database connection (the 1st +** parameter) of the sqlite3_create_function() and +** sqlite3_create_function16() routines that originally registered the +** application defined function. */ sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){ assert( p && p->pFunc );