/ Check-in [384d0ca9]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Replace a few sqlite3_malloc() calls that should be sqlite3MallocZero(). (CVS 4234)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 384d0ca9bc96309e7057e4a2bd4bac5049485e9b
User & Date: danielk1977 2007-08-16 10:36:34
Context
2007-08-16
11:36
Fix some more small problems introduced by recent refactoring. (CVS 4235) check-in: 5e2795d0 user: danielk1977 tags: trunk
10:36
Replace a few sqlite3_malloc() calls that should be sqlite3MallocZero(). (CVS 4234) check-in: 384d0ca9 user: danielk1977 tags: trunk
10:09
More work on refactoring of malloc() interfaces. There are still many errors. (CVS 4233) check-in: 77b16713 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/func.c.

    12     12   ** This file contains the C functions that implement various SQL
    13     13   ** functions of SQLite.  
    14     14   **
    15     15   ** There is only one exported symbol in this file - the function
    16     16   ** sqliteRegisterBuildinFunctions() found at the bottom of the file.
    17     17   ** All other code has file scope.
    18     18   **
    19         -** $Id: func.c,v 1.165 2007/08/16 10:09:03 danielk1977 Exp $
           19  +** $Id: func.c,v 1.166 2007/08/16 10:36:34 danielk1977 Exp $
    20     20   */
    21     21   #include "sqliteInt.h"
    22     22   #include <ctype.h>
    23     23   /* #include <math.h> */
    24     24   #include <stdlib.h>
    25     25   #include <assert.h>
    26     26   #include "vdbeInt.h"
................................................................................
  1061   1061     int len;
  1062   1062     sqlite3 *db = sqlite3_user_data(pCtx);
  1063   1063    
  1064   1064     test_destructor_count_var++;
  1065   1065     assert( nArg==1 );
  1066   1066     if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
  1067   1067     len = sqlite3ValueBytes(0, argv[0], ENC(db)); 
  1068         -  zVal = sqlite3_malloc(len+3);
         1068  +  zVal = sqlite3MallocZero(len+3);
  1069   1069     zVal[len] = 0;
  1070   1070     zVal[len-1] = 0;
  1071   1071     assert( zVal );
  1072   1072     zVal++;
  1073   1073     memcpy(zVal, sqlite3ValueText(0, argv[0], ENC(db)), len);
  1074   1074     if( ENC(db)==SQLITE_UTF8 ){
  1075   1075       sqlite3_result_text(pCtx, zVal, -1, destructor);
................................................................................
  1105   1105   static void free_test_auxdata(void *p) {sqlite3_free(p);}
  1106   1106   static void test_auxdata(
  1107   1107     sqlite3_context *pCtx, 
  1108   1108     int nArg,
  1109   1109     sqlite3_value **argv
  1110   1110   ){
  1111   1111     int i;
  1112         -  char *zRet = sqlite3_malloc(nArg*2);
         1112  +  char *zRet = sqlite3MallocZero(nArg*2);
  1113   1113     if( !zRet ) return;
  1114   1114     for(i=0; i<nArg; i++){
  1115   1115       char const *z = (char*)sqlite3_value_text(argv[i]);
  1116   1116       if( z ){
  1117   1117         char *zAux = sqlite3_get_auxdata(pCtx, i);
  1118   1118         if( zAux ){
  1119   1119           zRet[i*2] = '1';

Changes to src/vdbemem.c.

   880    880     }
   881    881   }
   882    882   
   883    883   /*
   884    884   ** Create a new sqlite3_value object.
   885    885   */
   886    886   sqlite3_value *sqlite3ValueNew(sqlite3 *db){
   887         -  Mem *p = sqlite3_malloc(sizeof(*p));
          887  +  Mem *p = sqlite3MallocZero(sizeof(*p));
   888    888     if( p ){
   889    889       p->flags = MEM_Null;
   890    890       p->type = SQLITE_NULL;
   891    891     }else{
   892    892       db->mallocFailed = 1;
   893    893     }
   894    894     return p;