/ Check-in [85a66a25]
Login

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

Overview
Comment:Publish APIs sqlite3_malloc() and sqlite3_realloc() that use the OS-layer memory allocator. Convert sqlite3_free() and sqlite3_mprintf() to also use the OS-layer memory allocator. (CVS 3298)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 85a66a25e97471d3c459c8da6a96990b0537dc7d
User & Date: drh 2006-06-26 21:35:45
Context
2006-06-27
00:14
Export the sqlite3_bind_value API to loadable extensions. (CVS 3299) check-in: 1ca385bb user: drh tags: trunk
2006-06-26
21:35
Publish APIs sqlite3_malloc() and sqlite3_realloc() that use the OS-layer memory allocator. Convert sqlite3_free() and sqlite3_mprintf() to also use the OS-layer memory allocator. (CVS 3298) check-in: 85a66a25 user: drh tags: trunk
19:10
Remove the sqlite3_module.zName field which was used only for debugging. (CVS 3297) check-in: 74a3961f user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/legacy.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Main file for the SQLite library.  The routines in this file
    13     13   ** implement the programmer interface to the library.  Routines in
    14     14   ** other files are for internal use by SQLite and should not be
    15     15   ** accessed by users of the library.
    16     16   **
    17         -** $Id: legacy.c,v 1.14 2006/03/06 20:55:46 drh Exp $
           17  +** $Id: legacy.c,v 1.15 2006/06/26 21:35:45 drh Exp $
    18     18   */
    19     19   
    20     20   #include "sqliteInt.h"
    21     21   #include "os.h"
    22     22   #include <ctype.h>
    23     23   
    24     24   /*
................................................................................
   119    119   
   120    120   exec_out:
   121    121     if( pStmt ) sqlite3_finalize(pStmt);
   122    122     if( azCols ) sqliteFree(azCols);
   123    123   
   124    124     rc = sqlite3ApiExit(0, rc);
   125    125     if( rc!=SQLITE_OK && rc==sqlite3_errcode(db) && pzErrMsg ){
   126         -    *pzErrMsg = malloc(1+strlen(sqlite3_errmsg(db)));
          126  +    *pzErrMsg = sqlite3_malloc(1+strlen(sqlite3_errmsg(db)));
   127    127       if( *pzErrMsg ){
   128    128         strcpy(*pzErrMsg, sqlite3_errmsg(db));
   129    129       }
   130    130     }else if( pzErrMsg ){
   131    131       *pzErrMsg = 0;
   132    132     }
   133    133   
   134    134     return rc;
   135    135   }

Changes to src/loadext.c.

   153    153     sqlite3_get_auxdata,
   154    154     sqlite3_get_table,
   155    155     sqlite3_global_recover,
   156    156     sqlite3_interrupt,
   157    157     sqlite3_last_insert_rowid,
   158    158     sqlite3_libversion,
   159    159     sqlite3_libversion_number,
          160  +  sqlite3_malloc,
   160    161     sqlite3_mprintf,
   161    162     sqlite3_open,
   162    163     sqlite3_open16,
   163    164     sqlite3_prepare,
   164    165     sqlite3_prepare16,
   165    166     sqlite3_profile,
   166    167     sqlite3_progress_handler,
          168  +  sqlite3_realloc,
   167    169     sqlite3_reset,
   168    170     sqlite3_result_blob,
   169    171     sqlite3_result_double,
   170    172     sqlite3_result_error,
   171    173     sqlite3_result_error16,
   172    174     sqlite3_result_int,
   173    175     sqlite3_result_int64,

Changes to src/main.c.

    10     10   **
    11     11   *************************************************************************
    12     12   ** Main file for the SQLite library.  The routines in this file
    13     13   ** implement the programmer interface to the library.  Routines in
    14     14   ** other files are for internal use by SQLite and should not be
    15     15   ** accessed by users of the library.
    16     16   **
    17         -** $Id: main.c,v 1.348 2006/06/24 11:51:33 danielk1977 Exp $
           17  +** $Id: main.c,v 1.349 2006/06/26 21:35:45 drh Exp $
    18     18   */
    19     19   #include "sqliteInt.h"
    20     20   #include "os.h"
    21     21   #include <ctype.h>
    22     22   
    23     23   /*
    24     24   ** The following constant value is used by the SQLITE_BIGENDIAN and
................................................................................
   381    381   void sqlite3_interrupt(sqlite3 *db){
   382    382     if( !sqlite3SafetyCheck(db) ){
   383    383       db->flags |= SQLITE_Interrupt;
   384    384     }
   385    385   }
   386    386   
   387    387   /*
   388         -** Windows systems should call this routine to free memory that
   389         -** is returned in the in the errmsg parameter of sqlite3_open() when
   390         -** SQLite is a DLL.  For some reason, it does not work to call free()
   391         -** directly.
          388  +** Memory allocation routines that use SQLites internal memory
          389  +** memory allocator.  Depending on how SQLite is compiled, the
          390  +** internal memory allocator might be just an alias for the
          391  +** system default malloc/realloc/free.  Or the built-in allocator
          392  +** might do extra stuff like put sentinals around buffers to 
          393  +** check for overruns or look for memory leaks.
   392    394   **
   393         -** Note that we need to call free() not sqliteFree() here.
          395  +** Use sqlite3_free() to free memory returned by sqlite3_mprintf().
   394    396   */
   395         -void sqlite3_free(char *p){ free(p); }
          397  +void sqlite3_free(void *p){ if( p ) sqlite3OsFree(p); }
          398  +void *sqlite3_malloc(int nByte){ return nByte>0 ? sqlite3OsMalloc(nByte) : 0; }
          399  +void *sqlite3_realloc(void *pOld, int nByte){ 
          400  +  if( pOld ){
          401  +    if( nByte>0 ){
          402  +      return sqlite3OsRealloc(pOld, nByte);
          403  +    }else{
          404  +      sqlite3OsFree(pOld);
          405  +      return 0;
          406  +    }
          407  +  }else{
          408  +    return sqlite3_malloc(nByte);
          409  +  }
          410  +}
   396    411   
   397    412   /*
   398    413   ** This function is exactly the same as sqlite3_create_function(), except
   399    414   ** that it is designed to be called by internal code. The difference is
   400    415   ** that if a malloc() fails in sqlite3_create_function(), an error code
   401    416   ** is returned and the mallocFailed flag cleared. 
   402    417   */

Changes to src/printf.c.

   802    802     va_start(ap, zFormat);
   803    803     z = base_vprintf(printf_realloc, 1, zBase, sizeof(zBase), zFormat, ap);
   804    804     va_end(ap);
   805    805     return z;
   806    806   }
   807    807   
   808    808   /*
   809         -** Print into memory obtained from malloc().  Do not use the internal
   810         -** %-conversion extensions.  This routine is for use by external users.
          809  +** Print into memory obtained from sqlite3_malloc().  Omit the internal
          810  +** %-conversion extensions.
          811  +*/
          812  +char *sqlite3_vmprintf(const char *zFormat, va_list ap){
          813  +  char zBase[SQLITE_PRINT_BUF_SIZE];
          814  +  return base_vprintf(sqlite3_realloc, 0, zBase, sizeof(zBase), zFormat, ap);
          815  +}
          816  +
          817  +/*
          818  +** Print into memory obtained from sqlite3_malloc()().  Omit the internal
          819  +** %-conversion extensions.
   811    820   */
   812    821   char *sqlite3_mprintf(const char *zFormat, ...){
   813    822     va_list ap;
   814    823     char *z;
   815         -  char zBuf[200];
   816         -
   817         -  va_start(ap,zFormat);
   818         -  z = base_vprintf((void*(*)(void*,int))realloc, 0, 
   819         -                   zBuf, sizeof(zBuf), zFormat, ap);
          824  +  char zBase[SQLITE_PRINT_BUF_SIZE];
          825  +  va_start(ap, zFormat);
          826  +  z = base_vprintf(sqlite3_realloc, 0, zBase, sizeof(zBase), zFormat, ap);
   820    827     va_end(ap);
   821    828     return z;
   822    829   }
   823    830   
   824         -/* This is the varargs version of sqlite3_mprintf.  
   825         -*/
   826         -char *sqlite3_vmprintf(const char *zFormat, va_list ap){
   827         -  char zBuf[200];
   828         -  return base_vprintf((void*(*)(void*,int))realloc, 0,
   829         -                      zBuf, sizeof(zBuf), zFormat, ap);
   830         -}
   831         -
   832    831   /*
   833    832   ** sqlite3_snprintf() works like snprintf() except that it ignores the
   834    833   ** current locale settings.  This is important for SQLite because we
   835    834   ** are not able to use a "," as the decimal point in place of "." as
   836    835   ** specified by some locales.
   837    836   */
   838    837   char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){

Changes to src/sqlite.h.in.

     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   ** This header file defines the interface that the SQLite library
    13     13   ** presents to client programs.
    14     14   **
    15         -** @(#) $Id: sqlite.h.in,v 1.183 2006/06/26 19:10:32 drh Exp $
           15  +** @(#) $Id: sqlite.h.in,v 1.184 2006/06/26 21:35:45 drh Exp $
    16     16   */
    17     17   #ifndef _SQLITE3_H_
    18     18   #define _SQLITE3_H_
    19     19   #include <stdarg.h>     /* Needed for the definition of va_list */
    20     20   
    21     21   /*
    22     22   ** Make sure we can call this stuff from C++.
................................................................................
   401    401   **
   402    402   ** This second example is an SQL syntax error.  As a general rule you
   403    403   ** should always use %q instead of %s when inserting text into a string 
   404    404   ** literal.
   405    405   */
   406    406   char *sqlite3_mprintf(const char*,...);
   407    407   char *sqlite3_vmprintf(const char*, va_list);
   408         -void sqlite3_free(char *z);
   409    408   char *sqlite3_snprintf(int,char*,const char*, ...);
   410    409   
          410  +/*
          411  +** SQLite uses its own memory allocator.  On many installations, this
          412  +** memory allocator is identical to the standard malloc()/realloc()/free()
          413  +** and can be used interchangable.  On others, the implementations are
          414  +** different.  For maximum portability, it is best not to mix calls
          415  +** to the standard malloc/realloc/free with the sqlite versions.
          416  +*/
          417  +void *sqlite3_malloc(int);
          418  +void *sqlite3_realloc(void*, int);
          419  +void sqlite3_free(void*);
          420  +
   411    421   #ifndef SQLITE_OMIT_AUTHORIZATION
   412    422   /*
   413    423   ** This routine registers a callback with the SQLite library.  The
   414    424   ** callback is invoked (at compile-time, not at run-time) for each
   415    425   ** attempt to access a column of a table in the database.  The callback
   416    426   ** returns SQLITE_OK if access is allowed, SQLITE_DENY if the entire
   417    427   ** SQL statement should be aborted with an error and SQLITE_IGNORE

Changes to src/sqlite3ext.h.

    11     11   *************************************************************************
    12     12   ** This header file defines the SQLite interface for use by
    13     13   ** shared libraries that want to be imported as extensions into
    14     14   ** an SQLite instance.  Shared libraries that intend to be loaded
    15     15   ** as extensions by SQLite should #include this file instead of 
    16     16   ** sqlite3.h.
    17     17   **
    18         -** @(#) $Id: sqlite3ext.h,v 1.3 2006/06/16 21:13:22 drh Exp $
           18  +** @(#) $Id: sqlite3ext.h,v 1.4 2006/06/26 21:35:45 drh Exp $
    19     19   */
    20     20   #ifndef _SQLITE3EXT_H_
    21     21   #define _SQLITE3EXT_H_
    22     22   #include <sqlite3.h>
    23     23   
    24     24   typedef struct sqlite3_api_routines sqlite3_api_routines;
    25     25   
................................................................................
    91     91     void * (*get_auxdata)(sqlite3_context*,int);
    92     92     int  (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);
    93     93     int  (*global_recover)(void);
    94     94     void  (*interrupt)(sqlite3*);
    95     95     sqlite_int64  (*last_insert_rowid)(sqlite3*);
    96     96     const char * (*libversion)(void);
    97     97     int  (*libversion_number)(void);
           98  +  void *(*malloc)(int);
    98     99     char * (*mprintf)(const char*,...);
    99    100     int  (*open)(const char*,sqlite3**);
   100    101     int  (*open16)(const void*,sqlite3**);
   101    102     int  (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
   102    103     int  (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
   103    104     void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);
   104    105     void  (*progress_handler)(sqlite3*,int,int(*)(void*),void*);
          106  +  void *(*realloc)(void*,int);
   105    107     int  (*reset)(sqlite3_stmt*pStmt);
   106    108     void  (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));
   107    109     void  (*result_double)(sqlite3_context*,double);
   108    110     void  (*result_error)(sqlite3_context*,const char*,int);
   109    111     void  (*result_error16)(sqlite3_context*,const void*,int);
   110    112     void  (*result_int)(sqlite3_context*,int);
   111    113     void  (*result_int64)(sqlite3_context*,sqlite_int64);
................................................................................
   217    219   #define sqlite3_get_auxdata            sqlite3_api->get_auxdata
   218    220   #define sqlite3_get_table              sqlite3_api->get_table
   219    221   #define sqlite3_global_recover         sqlite3_api->global_recover
   220    222   #define sqlite3_interrupt              sqlite3_api->interrupt
   221    223   #define sqlite3_last_insert_rowid      sqlite3_api->last_insert_rowid
   222    224   #define sqlite3_libversion             sqlite3_api->libversion
   223    225   #define sqlite3_libversion_number      sqlite3_api->libversion_number
          226  +#define sqlite3_malloc                 sqlite3_api->malloc
   224    227   #define sqlite3_mprintf                sqlite3_api->mprintf
   225    228   #define sqlite3_open                   sqlite3_api->open
   226    229   #define sqlite3_open16                 sqlite3_api->open16
   227    230   #define sqlite3_prepare                sqlite3_api->prepare
   228    231   #define sqlite3_prepare16              sqlite3_api->prepare16
   229    232   #define sqlite3_profile                sqlite3_api->profile
   230    233   #define sqlite3_progress_handler       sqlite3_api->progress_handler
          234  +#define sqlite3_realloc                sqlite3_api->realloc
   231    235   #define sqlite3_reset                  sqlite3_api->reset
   232    236   #define sqlite3_result_blob            sqlite3_api->result_blob
   233    237   #define sqlite3_result_double          sqlite3_api->result_double
   234    238   #define sqlite3_result_error           sqlite3_api->result_error
   235    239   #define sqlite3_result_error16         sqlite3_api->result_error16
   236    240   #define sqlite3_result_int             sqlite3_api->result_int
   237    241   #define sqlite3_result_int64           sqlite3_api->result_int64

Changes to src/sqliteInt.h.

     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   ** Internal interface definitions for SQLite.
    13     13   **
    14         -** @(#) $Id: sqliteInt.h,v 1.513 2006/06/26 19:10:32 drh Exp $
           14  +** @(#) $Id: sqliteInt.h,v 1.514 2006/06/26 21:35:45 drh Exp $
    15     15   */
    16     16   #ifndef _SQLITEINT_H_
    17     17   #define _SQLITEINT_H_
    18     18   
    19     19   /*
    20     20   ** Extra interface definitions for those who need them
    21     21   */

Changes to src/table.c.

    55     55       need = nCol*2;
    56     56     }else{
    57     57       need = nCol;
    58     58     }
    59     59     if( p->nData + need >= p->nAlloc ){
    60     60       char **azNew;
    61     61       p->nAlloc = p->nAlloc*2 + need + 1;
    62         -    azNew = realloc( p->azResult, sizeof(char*)*p->nAlloc );
           62  +    azNew = sqlite3_realloc( p->azResult, sizeof(char*)*p->nAlloc );
    63     63       if( azNew==0 ) goto malloc_failed;
    64     64       p->azResult = azNew;
    65     65     }
    66     66   
    67     67     /* If this is the first row, then generate an extra row containing
    68     68     ** the names of all columns.
    69     69     */
    70     70     if( p->nRow==0 ){
    71     71       p->nColumn = nCol;
    72     72       for(i=0; i<nCol; i++){
    73     73         if( colv[i]==0 ){
    74     74           z = 0;
    75     75         }else{
    76         -        z = malloc( strlen(colv[i])+1 );
           76  +        z = sqlite3_malloc( strlen(colv[i])+1 );
    77     77           if( z==0 ) goto malloc_failed;
    78     78           strcpy(z, colv[i]);
    79     79         }
    80     80         p->azResult[p->nData++] = z;
    81     81       }
    82     82     }else if( p->nColumn!=nCol ){
    83     83       sqlite3SetString(&p->zErrMsg,
................................................................................
    90     90     /* Copy over the row data
    91     91     */
    92     92     if( argv!=0 ){
    93     93       for(i=0; i<nCol; i++){
    94     94         if( argv[i]==0 ){
    95     95           z = 0;
    96     96         }else{
    97         -        z = malloc( strlen(argv[i])+1 );
           97  +        z = sqlite3_malloc( strlen(argv[i])+1 );
    98     98           if( z==0 ) goto malloc_failed;
    99     99           strcpy(z, argv[i]);
   100    100         }
   101    101         p->azResult[p->nData++] = z;
   102    102       }
   103    103       p->nRow++;
   104    104     }
................................................................................
   136    136     res.zErrMsg = 0;
   137    137     res.nResult = 0;
   138    138     res.nRow = 0;
   139    139     res.nColumn = 0;
   140    140     res.nData = 1;
   141    141     res.nAlloc = 20;
   142    142     res.rc = SQLITE_OK;
   143         -  res.azResult = malloc( sizeof(char*)*res.nAlloc );
          143  +  res.azResult = sqlite3_malloc( sizeof(char*)*res.nAlloc );
   144    144     if( res.azResult==0 ) return SQLITE_NOMEM;
   145    145     res.azResult[0] = 0;
   146    146     rc = sqlite3_exec(db, zSql, sqlite3_get_table_cb, &res, pzErrMsg);
   147    147     if( res.azResult ){
   148    148       assert( sizeof(res.azResult[0])>= sizeof(res.nData) );
   149    149       res.azResult[0] = (char*)res.nData;
   150    150     }
   151    151     if( rc==SQLITE_ABORT ){
   152    152       sqlite3_free_table(&res.azResult[1]);
   153    153       if( res.zErrMsg ){
   154    154         if( pzErrMsg ){
   155         -        free(*pzErrMsg);
          155  +        sqlite3_free(*pzErrMsg);
   156    156           *pzErrMsg = sqlite3_mprintf("%s",res.zErrMsg);
   157    157         }
   158    158         sqliteFree(res.zErrMsg);
   159    159       }
   160    160       db->errCode = res.rc;
   161    161       return res.rc;
   162    162     }
................................................................................
   163    163     sqliteFree(res.zErrMsg);
   164    164     if( rc!=SQLITE_OK ){
   165    165       sqlite3_free_table(&res.azResult[1]);
   166    166       return rc;
   167    167     }
   168    168     if( res.nAlloc>res.nData ){
   169    169       char **azNew;
   170         -    azNew = realloc( res.azResult, sizeof(char*)*(res.nData+1) );
          170  +    azNew = sqlite3_realloc( res.azResult, sizeof(char*)*(res.nData+1) );
   171    171       if( azNew==0 ){
   172    172         sqlite3_free_table(&res.azResult[1]);
   173    173         return SQLITE_NOMEM;
   174    174       }
   175    175       res.nAlloc = res.nData+1;
   176    176       res.azResult = azNew;
   177    177     }
................................................................................
   188    188     char **azResult            /* Result returned from from sqlite3_get_table() */
   189    189   ){
   190    190     if( azResult ){
   191    191       int i, n;
   192    192       azResult--;
   193    193       if( azResult==0 ) return;
   194    194       n = (int)azResult[0];
   195         -    for(i=1; i<n; i++){ if( azResult[i] ) free(azResult[i]); }
   196         -    free(azResult);
          195  +    for(i=1; i<n; i++){ if( azResult[i] ) sqlite3_free(azResult[i]); }
          196  +    sqlite3_free(azResult);
   197    197     }
   198    198   }
   199    199   
   200    200   #endif /* SQLITE_OMIT_GET_TABLE */

Changes to src/test3.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing the btree.c module in SQLite.  This code
    13     13   ** is not included in the SQLite library.  It is used for automated
    14     14   ** testing of the SQLite library.
    15     15   **
    16         -** $Id: test3.c,v 1.65 2006/01/20 10:55:05 danielk1977 Exp $
           16  +** $Id: test3.c,v 1.66 2006/06/26 21:35:46 drh Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "pager.h"
    20     20   #include "btree.h"
    21     21   #include "tcl.h"
    22     22   #include <stdlib.h>
    23     23   #include <string.h>
................................................................................
   581    581       if( Tcl_GetInt(interp, argv[i+2], &aRoot[i]) ) return TCL_ERROR;
   582    582     }
   583    583   #ifndef SQLITE_OMIT_INTEGRITY_CHECK
   584    584     zResult = sqlite3BtreeIntegrityCheck(pBt, aRoot, nRoot);
   585    585   #else
   586    586     zResult = 0;
   587    587   #endif
          588  +  free(aRoot);
   588    589     if( zResult ){
   589    590       Tcl_AppendResult(interp, zResult, 0);
   590    591       sqliteFree(zResult); 
   591    592     }
   592    593     return TCL_OK;
   593    594   }
   594    595   

Changes to test/loadext.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script is in-memory database backend.
    13     13   #
    14         -# $Id: loadext.test,v 1.3 2006/06/17 14:12:48 drh Exp $
           14  +# $Id: loadext.test,v 1.4 2006/06/26 21:35:46 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   # The name of the test extension varies by operating system.
    20     20   #
    21     21   if {$::tcl_platform(platform) eq "windows"} {
................................................................................
    28     28   # exist, try to create it.  If unable to create it, then skip this
    29     29   # test file.
    30     30   #
    31     31   if {![file exists $testextension]} {
    32     32     set srcdir [file dir $testdir]/src
    33     33     set testextsrc $srcdir/test_loadext.c
    34     34     if {[catch {
    35         -    exec gcc -shared $testextsrc -o $testextension
           35  +    exec gcc -Wall -g -shared $testextsrc -o $testextension
    36     36     } msg]} {
    37     37       puts "Skipping loadext tests: Test extension not built..."
    38     38       puts $msg
    39     39       finish_test
    40     40       return
    41     41     }
    42     42   }

Changes to www/capi3ref.tcl.

     1         -set rcsid {$Id: capi3ref.tcl,v 1.40 2006/06/14 15:35:37 drh Exp $}
            1  +set rcsid {$Id: capi3ref.tcl,v 1.41 2006/06/26 21:35:46 drh Exp $}
     2      2   source common.tcl
     3      3   header {C/C++ Interface For SQLite Version 3}
     4      4   puts {
     5      5   <h2>C/C++ Interface For SQLite Version 3</h2>
     6      6   }
     7      7   
     8      8   proc api {name prototype desc {notused x}} {
................................................................................
   822    822    when this routine is called, that is like encountering an error or
   823    823    an interrupt.  (See sqlite3_interrupt().)  Incomplete updates may be
   824    824    rolled back and transactions canceled,  depending on the circumstances,
   825    825    and the result code returned will be SQLITE_ABORT.
   826    826   }
   827    827   
   828    828   api {} {
   829         -void sqlite3_free(char *z);
          829  +void *sqlite3_malloc(int);
          830  +void *sqlite3_realloc(void*, int);
          831  +void sqlite3_free(void*);
   830    832   } {
   831         - Use this routine to free memory obtained from 
   832         - sqlite3_mprintf() or sqlite3_vmprintf().
          833  + These routines provide access to the memory allocator used by SQLite.
          834  + Depending on how SQLite has been compiled and the OS-layer backend,
          835  + the memory allocator used by SQLite might be the standard system
          836  + malloc()/realloc()/free(), or it might be something different.  With
          837  + certain compile-time flags, SQLite will add wrapper logic around the
          838  + memory allocator to add memory leak and buffer overrun detection.  The
          839  + OS layer might substitute a completely different memory allocator.
          840  + Use these APIs to be sure you are always using the correct memory
          841  + allocator.
          842  + 
          843  + The sqlite3_free() API, not the standard free() from the system library,
          844  + should always be used to free the memory buffer returned by
          845  + sqlite3_mprintf() or sqlite3_vmprintf() and to free the error message
          846  + string returned by sqlite3_exec().  Using free() instead of sqlite3_free()
          847  + might accidentally work on some systems and build configurations but 
          848  + will fail on others.
          849  +
          850  + Compatibility Note:  Prior to version 3.4.0, the sqlite3_free API
          851  + was prototyped to take a <tt>char*</tt> parameter rather than 
          852  + <tt>void*</tt>.  Like this:
          853  +<blockquote><pre>
          854  +void sqlite3_free(char*);
          855  +</pre></blockquote>
          856  + The change to using <tt>void*</tt> might cause warnings when 
          857  + compiling older code against
          858  + newer libraries, but everything should still work correctly.
   833    859   }
   834    860   
   835    861   api {} {
   836    862   int sqlite3_get_table(
   837    863     sqlite3*,              /* An open database */
   838    864     const char *sql,       /* SQL to be executed */
   839    865     char ***resultp,       /* Result written to a char *[]  that this points to */