System.Data.SQLite
Check-in [3b2c842774]
Not logged in

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

Overview
Comment:Document the SQLiteMemory class.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | virtualTables
Files: files | file ages | folders
SHA1: 3b2c842774dd4d53448e7274d79d332cc9815013
User & Date: mistachkin 2013-06-25 06:58:42
Context
2013-06-25
07:44
Document the SQLiteString class. In the SQLiteString.ProbeForUtf8ByteLength method, make sure the limit is greater than zero. check-in: 3fbdd30433 user: mistachkin tags: virtualTables
06:58
Document the SQLiteMemory class. check-in: 3b2c842774 user: mistachkin tags: virtualTables
06:40
More work on docs. check-in: f31a811fbb user: mistachkin tags: virtualTables
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Doc/buildChm.tcl.

    83     83   
    84     84   set data [readFile $xmlDocFile]
    85     85   set count 0
    86     86   
    87     87   set pattern { cref="([A-Z]):System\.Data\.SQLite\.}
    88     88   incr count [regsub -all -- $pattern $data { cref="\1:system.Data.SQLite.} data]
    89     89   
    90         -set pattern { name="([A-Z]):System\.Data\.SQLite\.}
    91         -incr count [regsub -all -- $pattern $data { name="\1:system.Data.SQLite.} data]
    92         -
    93     90   if {$count > 0} then {
    94     91     writeFile $xmlDocFile $data
    95     92   } else {
    96     93     puts stdout "*WARNING* File \"$xmlDocFile\" does not match: $pattern"
    97     94   }
    98     95   
    99     96   #

Changes to System.Data.SQLite/SQLiteModule.cs.

  3358   3358               );
  3359   3359       }
  3360   3360       #endregion
  3361   3361   
  3362   3362       ///////////////////////////////////////////////////////////////////////////
  3363   3363   
  3364   3364       #region SQLiteMemory Static Class
         3365  +    /// <summary>
         3366  +    /// This class contains static methods that are used to allocate,
         3367  +    /// manipulate, and free native memory provided by the SQLite core library.
         3368  +    /// </summary>
  3365   3369       internal static class SQLiteMemory
  3366   3370       {
  3367   3371           #region Private Data
  3368   3372   #if TRACK_MEMORY_BYTES
         3373  +        /// <summary>
         3374  +        /// This object instance is used to synchronize access to the other
         3375  +        /// static fields of this class.
         3376  +        /// </summary>
  3369   3377           private static object syncRoot = new object();
  3370   3378   
  3371   3379           ///////////////////////////////////////////////////////////////////////
  3372   3380   
         3381  +        /// <summary>
         3382  +        /// The total number of outstanding memory bytes allocated by this
         3383  +        /// class using the SQLite core library.
         3384  +        /// </summary>
  3373   3385           private static int bytesAllocated;
         3386  +
         3387  +        ///////////////////////////////////////////////////////////////////////
         3388  +
         3389  +        /// <summary>
         3390  +        /// The maximum number of outstanding memory bytes ever allocated by
         3391  +        /// this class using the SQLite core library.
         3392  +        /// </summary>
  3374   3393           private static int maximumBytesAllocated;
  3375   3394   #endif
  3376   3395           #endregion
  3377   3396   
  3378   3397           ///////////////////////////////////////////////////////////////////////
  3379   3398   
  3380   3399           #region Memory Allocation Helper Methods
         3400  +        /// <summary>
         3401  +        /// Allocates at least the specified number of bytes of native memory
         3402  +        /// via the SQLite core library sqlite3_malloc() function and returns
         3403  +        /// the resulting native pointer.
         3404  +        /// </summary>
         3405  +        /// <param name="size">
         3406  +        /// The number of bytes to allocate.
         3407  +        /// </param>
         3408  +        /// <returns>
         3409  +        /// The native pointer that points to a block of memory of at least the
         3410  +        /// specified size -OR- <see cref="IntPtr.Zero" /> if the memory could
         3411  +        /// not be allocated.
         3412  +        /// </returns>
  3381   3413           public static IntPtr Allocate(int size)
  3382   3414           {
  3383   3415               IntPtr pMemory = UnsafeNativeMethods.sqlite3_malloc(size);
  3384   3416   
  3385   3417   #if TRACK_MEMORY_BYTES
  3386   3418               if (pMemory != IntPtr.Zero)
  3387   3419               {
................................................................................
  3401   3433   #endif
  3402   3434   
  3403   3435               return pMemory;
  3404   3436           }
  3405   3437   
  3406   3438           ///////////////////////////////////////////////////////////////////////
  3407   3439   
         3440  +        /// <summary>
         3441  +        /// Gets and returns the actual size of the specified memory block that
         3442  +        /// was previously obtained from the <see cref="Allocate" /> method.
         3443  +        /// </summary>
         3444  +        /// <param name="pMemory">
         3445  +        /// The native pointer to the memory block previously obtained from the
         3446  +        /// <see cref="Allocate" /> method.
         3447  +        /// </param>
         3448  +        /// <returns>
         3449  +        /// The actual size, in bytes, of the memory block specified via the
         3450  +        /// native pointer.
         3451  +        /// </returns>
  3408   3452           public static int Size(IntPtr pMemory)
  3409   3453           {
  3410   3454   #if !SQLITE_STANDARD
  3411   3455               return UnsafeNativeMethods.sqlite3_malloc_size_interop(pMemory);
  3412   3456   #else
  3413   3457               return 0;
  3414   3458   #endif
  3415   3459           }
  3416   3460   
  3417   3461           ///////////////////////////////////////////////////////////////////////
  3418   3462   
         3463  +        /// <summary>
         3464  +        /// Frees a memory block previously obtained from the
         3465  +        /// <see cref="Allocate" /> method.
         3466  +        /// </summary>
         3467  +        /// <param name="pMemory">
         3468  +        /// The native pointer to the memory block previously obtained from the
         3469  +        /// <see cref="Allocate" /> method.
         3470  +        /// </param>
  3419   3471           public static void Free(IntPtr pMemory)
  3420   3472           {
  3421   3473   #if TRACK_MEMORY_BYTES
  3422   3474               if (pMemory != IntPtr.Zero)
  3423   3475               {
  3424   3476                   int blockSize = Size(pMemory);
  3425   3477