/ Check-in [e5e6a848]
Login

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

Overview
Comment:Use sqlite_freemem() instead of free() in the shell. Windows needs this. (Unix does not care.) Ticket #444. (CVS 1125)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e5e6a8481b2225e826c8e890ddc44f06759fe72b
User & Date: drh 2003-12-04 20:51:41
Context
2003-12-06
21:43
Always use "(char*)0" to terminate the argument list of sqliteSetString(). This is needed for 64-bit systems that use a 32-bit integer by default. (CVS 1126) check-in: 656c9038 user: drh tags: trunk
2003-12-04
20:51
Use sqlite_freemem() instead of free() in the shell. Windows needs this. (Unix does not care.) Ticket #444. (CVS 1125) check-in: e5e6a848 user: drh tags: trunk
13:47
Version 2.8.7 (CVS 1124) check-in: d48b0b01 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

     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 file contains code to implement the "sqlite" command line
    13     13   ** utility for accessing SQLite databases.
    14     14   **
    15         -** $Id: shell.c,v 1.82 2003/07/18 01:30:59 drh Exp $
           15  +** $Id: shell.c,v 1.83 2003/12/04 20:51:41 drh Exp $
    16     16   */
    17     17   #include <stdlib.h>
    18     18   #include <string.h>
    19     19   #include <stdio.h>
    20     20   #include "sqlite.h"
    21     21   #include <ctype.h>
    22     22   
................................................................................
   567    567       open_db(p);
   568    568       memcpy(&data, p, sizeof(data));
   569    569       data.showHeader = 0;
   570    570       data.mode = MODE_Column;
   571    571       sqlite_exec(p->db, "PRAGMA database_list; ", callback, &data, &zErrMsg);
   572    572       if( zErrMsg ){
   573    573         fprintf(stderr,"Error: %s\n", zErrMsg);
   574         -      free(zErrMsg);
          574  +      sqlite_freemem(zErrMsg);
   575    575       }
   576    576     }else
   577    577   
   578    578     if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){
   579    579       char *zErrMsg = 0;
   580    580       open_db(p);
   581    581       fprintf(p->out, "BEGIN TRANSACTION;\n");
................................................................................
   595    595             "ORDER BY substr(type,2,1), name",
   596    596             dump_callback, p, &zErrMsg, azArg[i]
   597    597           );
   598    598         }
   599    599       }
   600    600       if( zErrMsg ){
   601    601         fprintf(stderr,"Error: %s\n", zErrMsg);
   602         -      free(zErrMsg);
          602  +      sqlite_freemem(zErrMsg);
   603    603       }else{
   604    604         fprintf(p->out, "COMMIT;\n");
   605    605       }
   606    606     }else
   607    607   
   608    608     if( c=='e' && strncmp(azArg[0], "echo", n)==0 && nArg>1 ){
   609    609       int j;
................................................................................
   701    701         "SELECT name FROM sqlite_temp_master "
   702    702         "WHERE type='index' AND tbl_name LIKE '%q' "
   703    703         "ORDER BY 1",
   704    704         callback, &data, &zErrMsg, azArg[1], azArg[1]
   705    705       );
   706    706       if( zErrMsg ){
   707    707         fprintf(stderr,"Error: %s\n", zErrMsg);
   708         -      free(zErrMsg);
          708  +      sqlite_freemem(zErrMsg);
   709    709       }
   710    710     }else
   711    711   
   712    712     if( c=='m' && strncmp(azArg[0], "mode", n)==0 && nArg>=2 ){
   713    713       int n2 = strlen(azArg[1]);
   714    714       if( strncmp(azArg[1],"line",n2)==0
   715    715           ||
................................................................................
   833    833            "WHERE type!='meta' AND sql NOTNULL "
   834    834            "ORDER BY substr(type,2,1), name",
   835    835            callback, &data, &zErrMsg
   836    836         );
   837    837       }
   838    838       if( zErrMsg ){
   839    839         fprintf(stderr,"Error: %s\n", zErrMsg);
   840         -      free(zErrMsg);
          840  +      sqlite_freemem(zErrMsg);
   841    841       }
   842    842     }else
   843    843   
   844    844     if( c=='s' && strncmp(azArg[0], "separator", n)==0 && nArg==2 ){
   845    845       sprintf(p->separator, "%.*s", (int)ArraySize(p->separator)-1, azArg[1]);
   846    846     }else
   847    847   
................................................................................
   886    886           "WHERE type IN ('table','view') AND name LIKE '%%%q%%' "
   887    887           "ORDER BY 1",
   888    888           &azResult, &nRow, 0, &zErrMsg, azArg[1], azArg[1]
   889    889         );
   890    890       }
   891    891       if( zErrMsg ){
   892    892         fprintf(stderr,"Error: %s\n", zErrMsg);
   893         -      free(zErrMsg);
          893  +      sqlite_freemem(zErrMsg);
   894    894       }
   895    895       if( rc==SQLITE_OK ){
   896    896         int len, maxlen = 0;
   897    897         int i, j;
   898    898         int nPrintCol, nPrintRow;
   899    899         for(i=1; i<=nRow; i++){
   900    900           if( azResult[i]==0 ) continue;
................................................................................
  1036   1036         p->cnt = 0;
  1037   1037         open_db(p);
  1038   1038         rc = sqlite_exec(p->db, zSql, callback, p, &zErrMsg);
  1039   1039         if( rc || zErrMsg ){
  1040   1040           if( in!=0 && !p->echoOn ) printf("%s\n",zSql);
  1041   1041           if( zErrMsg!=0 ){
  1042   1042             printf("SQL error: %s\n", zErrMsg);
  1043         -          free(zErrMsg);
         1043  +          sqlite_freemem(zErrMsg);
  1044   1044             zErrMsg = 0;
  1045   1045           }else{
  1046   1046             printf("SQL error: %s\n", sqlite_error_string(rc));
  1047   1047           }
  1048   1048         }
  1049   1049         free(zSql);
  1050   1050         zSql = 0;