/ Check-in [e9c2adbc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add data structure description comments to memjournal.c. (CVS 5847)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e9c2adbcbf5c28837b06e0fbba93f1764cc3607f
User & Date: drh 2008-10-28 18:12:36
Context
2008-10-28
18:58
Remove the vestigial mem4 and mem6 memory allocators. Add the SQLITE_ZERO_MALLOC compile-time option and the mem0.c module to handle memory allocation for that case. (CVS 5848) check-in: 4651f590 user: drh tags: trunk
18:12
Add data structure description comments to memjournal.c. (CVS 5847) check-in: e9c2adbc user: drh tags: trunk
17:52
Avoid exposing internal interfaces sqlite_attach() and sqlite_detach() as SQL scalar functions. Ticket #3466. (CVS 5846) check-in: 679c0b35 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/memjournal.c.

     1      1   /*
     2         -** 2007 August 22
            2  +** 2008 October 7
     3      3   **
     4      4   ** The author disclaims copyright to this source code.  In place of
     5      5   ** a legal notice, here is a blessing:
     6      6   **
     7      7   **    May you do good and not evil.
     8      8   **    May you find forgiveness for yourself and forgive others.
     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   **
    13         -** @(#) $Id: memjournal.c,v 1.1 2008/10/17 19:13:05 danielk1977 Exp $
           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
           15  +** ":memory:" databases and when the journal_mode=MEMORY pragma is used.
           16  +**
           17  +** @(#) $Id: memjournal.c,v 1.2 2008/10/28 18:12:36 drh Exp $
    14     18   */
    15         -
    16         -
    17     19   #include "sqliteInt.h"
    18     20   
           21  +/* Forward references to internal structures */
    19     22   typedef struct MemJournal MemJournal;
    20     23   typedef struct FilePoint FilePoint;
    21     24   typedef struct FileChunk FileChunk;
    22     25   
           26  +/* Space to hold the rollback journal is allocated in increments of
           27  +** this many bytes.
           28  +*/
    23     29   #define JOURNAL_CHUNKSIZE 1024
    24     30   
           31  +/* Macro to find the minimum of two numeric values.
           32  +*/
    25     33   #define MIN(x,y) ((x)<(y)?(x):(y))
    26     34   
           35  +/*
           36  +** The rollback journal is composed of a linked list of these structures.
           37  +*/
    27     38   struct FileChunk {
    28         -  FileChunk *pNext;
    29         -  u8 zChunk[JOURNAL_CHUNKSIZE];
           39  +  FileChunk *pNext;               /* Next chunk in the journal */
           40  +  u8 zChunk[JOURNAL_CHUNKSIZE];   /* Content of this chunk */
    30     41   };
    31     42   
           43  +/*
           44  +** An instance of this object serves as a cursor into the rollback journal.
           45  +** The cursor can be either for reading or writing.
           46  +*/
    32     47   struct FilePoint {
    33         -  sqlite3_int64 iOffset;
    34         -  FileChunk *pChunk;
           48  +  sqlite3_int64 iOffset;          /* Offset from the beginning of the file */
           49  +  FileChunk *pChunk;              /* Specific chunk into which cursor points */
    35     50   };
    36     51   
           52  +/*
           53  +** This subclass is a subclass of sqlite3_file.  Each open memory-journal
           54  +** is an instance of this class.
           55  +*/
    37     56   struct MemJournal {
    38         -  sqlite3_io_methods *pMethod;    /* I/O methods on journal files */
           57  +  sqlite3_io_methods *pMethod;    /* Parent class. MUST BE FIRST */
    39     58     FileChunk *pFirst;              /* Head of in-memory chunk-list */
    40     59     FilePoint endpoint;             /* Pointer to the end of the file */
    41     60     FilePoint readpoint;            /* Pointer to the end of the last xRead() */
    42     61   };
    43     62   
    44     63   /*
    45     64   ** Read data from the file.
................................................................................
   215    234   /* 
   216    235   ** Return the number of bytes required to store a MemJournal that uses vfs
   217    236   ** pVfs to create the underlying on-disk files.
   218    237   */
   219    238   int sqlite3MemJournalSize(){
   220    239     return sizeof(MemJournal);
   221    240   }
   222         -
   223         -