/ Check-in [ee1e6896]
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:Further reforms to Tcl_*Alloc() usage.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: ee1e689633e517ce46307b9afbf1eda03482c928
User & Date: mistachkin 2017-02-15 04:16:56
Context
2017-02-15
15:09
Remove the CLANG_VERSION macro, since we have learned that version numbers in clang are "marketing" and are inconsistent and unreliable. Builds using clang will still use the GCC_VERSION macro since clang works hard to be gcc compatible. check-in: 810d2932 user: drh tags: trunk
04:16
Further reforms to Tcl_*Alloc() usage. check-in: ee1e6896 user: mistachkin tags: trunk
01:39
In the blob test code, avoid crashing on low-memory systems by using Tcl_AttemptAlloc(). check-in: 1d267757 user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/tclsqlite.c.

  3401   3401         " ?-key CODECKEY?"
  3402   3402   #endif
  3403   3403       );
  3404   3404       return TCL_ERROR;
  3405   3405     }
  3406   3406     zErrMsg = 0;
  3407   3407     p = (SqliteDb*)Tcl_Alloc( sizeof(*p) );
  3408         -  if( p==0 ){
  3409         -    Tcl_SetResult(interp, (char *)"malloc failed", TCL_STATIC);
  3410         -    return TCL_ERROR;
  3411         -  }
  3412   3408     memset(p, 0, sizeof(*p));
  3413   3409     zFile = Tcl_GetStringFromObj(objv[2], 0);
  3414   3410     zFile = Tcl_TranslateFileName(interp, zFile, &translatedFilename);
  3415   3411     rc = sqlite3_open_v2(zFile, &p->db, flags, zVfs);
  3416   3412     Tcl_DStringFree(&translatedFilename);
  3417   3413     if( p->db ){
  3418   3414       if( SQLITE_OK!=sqlite3_errcode(p->db) ){

Changes to src/test6.c.

   157    157   
   158    158   /*
   159    159   ** Set this global variable to 1 to enable crash testing.
   160    160   */
   161    161   static int sqlite3CrashTestEnable = 0;
   162    162   
   163    163   static void *crash_malloc(int nByte){
   164         -  return (void *)Tcl_Alloc((size_t)nByte);
          164  +  return (void *)Tcl_AttemptAlloc((size_t)nByte);
   165    165   }
   166    166   static void crash_free(void *p){
   167    167     Tcl_Free(p);
   168    168   }
   169    169   static void *crash_realloc(void *p, int n){
   170         -  return (void *)Tcl_Realloc(p, (size_t)n);
          170  +  return (void *)Tcl_AttemptRealloc(p, (size_t)n);
   171    171   }
   172    172   
   173    173   /*
   174    174   ** Wrapper around the sqlite3OsWrite() function that avoids writing to the
   175    175   ** 512 byte block begining at offset PENDING_BYTE.
   176    176   */
   177    177   static int writeDbFile(CrashFile *p, u8 *z, i64 iAmt, i64 iOff){