Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/sqlite/sqlite-src-3080704/src/memjournal.c

Issue 883353008: [sql] Import reference version of SQLite 3.8.7.4. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Hold back encoding change which is messing up patch. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 ** 2008 October 7 2 ** 2008 October 7
3 ** 3 **
4 ** The author disclaims copyright to this source code. In place of 4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing: 5 ** a legal notice, here is a blessing:
6 ** 6 **
7 ** May you do good and not evil. 7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others. 8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give. 9 ** May you share freely, never taking more than you give.
10 ** 10 **
11 ************************************************************************* 11 *************************************************************************
12 ** 12 **
13 ** This file contains code use to implement an in-memory rollback journal. 13 ** This file contains code use to implement an in-memory rollback journal.
14 ** The in-memory rollback journal is used to journal transactions for 14 ** The in-memory rollback journal is used to journal transactions for
15 ** ":memory:" databases and when the journal_mode=MEMORY pragma is used. 15 ** ":memory:" databases and when the journal_mode=MEMORY pragma is used.
16 */ 16 */
17 #include "sqliteInt.h" 17 #include "sqliteInt.h"
18 18
19 /* Forward references to internal structures */ 19 /* Forward references to internal structures */
20 typedef struct MemJournal MemJournal; 20 typedef struct MemJournal MemJournal;
21 typedef struct FilePoint FilePoint; 21 typedef struct FilePoint FilePoint;
22 typedef struct FileChunk FileChunk; 22 typedef struct FileChunk FileChunk;
23 23
24 /* Space to hold the rollback journal is allocated in increments of 24 /* Space to hold the rollback journal is allocated in increments of
25 ** this many bytes. 25 ** this many bytes.
26 ** 26 **
27 ** The size chosen is a little less than a power of two. That way, 27 ** The size chosen is a little less than a power of two. That way,
28 ** the FileChunk object will have a size that almost exactly fills 28 ** the FileChunk object will have a size that almost exactly fills
29 ** a power-of-two allocation. This mimimizes wasted space in power-of-two 29 ** a power-of-two allocation. This minimizes wasted space in power-of-two
30 ** memory allocators. 30 ** memory allocators.
31 */ 31 */
32 #define JOURNAL_CHUNKSIZE ((int)(1024-sizeof(FileChunk*))) 32 #define JOURNAL_CHUNKSIZE ((int)(1024-sizeof(FileChunk*)))
33 33
34 /* Macro to find the minimum of two numeric values.
35 */
36 #ifndef MIN
37 # define MIN(x,y) ((x)<(y)?(x):(y))
38 #endif
39
40 /* 34 /*
41 ** The rollback journal is composed of a linked list of these structures. 35 ** The rollback journal is composed of a linked list of these structures.
42 */ 36 */
43 struct FileChunk { 37 struct FileChunk {
44 FileChunk *pNext; /* Next chunk in the journal */ 38 FileChunk *pNext; /* Next chunk in the journal */
45 u8 zChunk[JOURNAL_CHUNKSIZE]; /* Content of this chunk */ 39 u8 zChunk[JOURNAL_CHUNKSIZE]; /* Content of this chunk */
46 }; 40 };
47 41
48 /* 42 /*
49 ** An instance of this object serves as a cursor into the rollback journal. 43 ** An instance of this object serves as a cursor into the rollback journal.
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 memjrnlFileSize, /* xFileSize */ 217 memjrnlFileSize, /* xFileSize */
224 0, /* xLock */ 218 0, /* xLock */
225 0, /* xUnlock */ 219 0, /* xUnlock */
226 0, /* xCheckReservedLock */ 220 0, /* xCheckReservedLock */
227 0, /* xFileControl */ 221 0, /* xFileControl */
228 0, /* xSectorSize */ 222 0, /* xSectorSize */
229 0, /* xDeviceCharacteristics */ 223 0, /* xDeviceCharacteristics */
230 0, /* xShmMap */ 224 0, /* xShmMap */
231 0, /* xShmLock */ 225 0, /* xShmLock */
232 0, /* xShmBarrier */ 226 0, /* xShmBarrier */
233 0 /* xShmUnlock */ 227 0, /* xShmUnmap */
228 0, /* xFetch */
229 0 /* xUnfetch */
234 }; 230 };
235 231
236 /* 232 /*
237 ** Open a journal file. 233 ** Open a journal file.
238 */ 234 */
239 void sqlite3MemJournalOpen(sqlite3_file *pJfd){ 235 void sqlite3MemJournalOpen(sqlite3_file *pJfd){
240 MemJournal *p = (MemJournal *)pJfd; 236 MemJournal *p = (MemJournal *)pJfd;
241 assert( EIGHT_BYTE_ALIGNMENT(p) ); 237 assert( EIGHT_BYTE_ALIGNMENT(p) );
242 memset(p, 0, sqlite3MemJournalSize()); 238 memset(p, 0, sqlite3MemJournalSize());
243 p->pMethod = (sqlite3_io_methods*)&MemJournalMethods; 239 p->pMethod = (sqlite3_io_methods*)&MemJournalMethods;
244 } 240 }
245 241
246 /* 242 /*
247 ** Return true if the file-handle passed as an argument is 243 ** Return true if the file-handle passed as an argument is
248 ** an in-memory journal 244 ** an in-memory journal
249 */ 245 */
250 int sqlite3IsMemJournal(sqlite3_file *pJfd){ 246 int sqlite3IsMemJournal(sqlite3_file *pJfd){
251 return pJfd->pMethods==&MemJournalMethods; 247 return pJfd->pMethods==&MemJournalMethods;
252 } 248 }
253 249
254 /* 250 /*
255 ** Return the number of bytes required to store a MemJournal file descriptor. 251 ** Return the number of bytes required to store a MemJournal file descriptor.
256 */ 252 */
257 int sqlite3MemJournalSize(void){ 253 int sqlite3MemJournalSize(void){
258 return sizeof(MemJournal); 254 return sizeof(MemJournal);
259 } 255 }
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3080704/src/mem5.c ('k') | third_party/sqlite/sqlite-src-3080704/src/mutex.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698