Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Change the name of the sqlite3_freemem API function to just sqlite3_free. (CVS 1512) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f3b80bbb97ed0b0c1cf634068f28f238 |
User & Date: | drh 2004-05-31 19:34:33.000 |
Context
2004-05-31
| ||
23:13 | Synchronize lemon.c to the version on the 2.8 branch. (CVS 1513) (check-in: 6ab3af8847 user: drh tags: trunk) | |
19:34 | Change the name of the sqlite3_freemem API function to just sqlite3_free. (CVS 1512) (check-in: f3b80bbb97 user: drh tags: trunk) | |
18:51 | Change all SQLITE3 preprocessor macros to SQLITE. Documentation updates. (CVS 1511) (check-in: adf7e29ff6 user: drh tags: trunk) | |
Changes
Changes to src/main.c.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** ** $Id: main.c,v 1.200 2004/05/31 19:34:33 drh Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> /* ** A pointer to this structure is used to communicate information |
︙ | ︙ | |||
87 88 89 90 91 92 93 | char *zErr; assert( db->init.busy ); db->init.iDb = atoi(argv[4]); assert( db->init.iDb>=0 && db->init.iDb<db->nDb ); db->init.newTnum = atoi(argv[2]); if( sqlite3_exec(db, argv[3], 0, 0, &zErr) ){ corruptSchema(pData, zErr); | | | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | char *zErr; assert( db->init.busy ); db->init.iDb = atoi(argv[4]); assert( db->init.iDb>=0 && db->init.iDb<db->nDb ); db->init.newTnum = atoi(argv[2]); if( sqlite3_exec(db, argv[3], 0, 0, &zErr) ){ corruptSchema(pData, zErr); sqlite3_free(zErr); } db->init.iDb = 0; }else{ /* If the SQL column is blank it means this is an index that ** was created to be the PRIMARY KEY or to fulfill a UNIQUE ** constraint for a CREATE TABLE. The index should have already ** been created when we processed the CREATE TABLE. All we have |
︙ | ︙ | |||
634 635 636 637 638 639 640 | ** SQLite is a DLL. For some reason, it does not work to call free() ** directly. ** ** Note that we need to call free() not sqliteFree() here, since every ** string that is exported from SQLite should have already passed through ** sqlite3StrRealloc(). */ | | | 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 | ** SQLite is a DLL. For some reason, it does not work to call free() ** directly. ** ** Note that we need to call free() not sqliteFree() here, since every ** string that is exported from SQLite should have already passed through ** sqlite3StrRealloc(). */ void sqlite3_free(char *p){ free(p); } /* ** Windows systems need functions to call to return the sqlite3_version ** and sqlite3_encoding strings since they are unable to access constants ** within DLLs. */ const char *sqlite3_libversion(void){ return sqlite3_version; } |
︙ | ︙ |
Changes to src/shell.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. ** ** $Id: shell.c,v 1.100 2004/05/31 19:34:33 drh Exp $ */ #include <stdlib.h> #include <string.h> #include <stdio.h> #include "sqlite3.h" #include <ctype.h> |
︙ | ︙ | |||
572 573 574 575 576 577 578 | data.mode = MODE_Column; data.colWidth[0] = 3; data.colWidth[1] = 15; data.colWidth[2] = 58; sqlite3_exec(p->db, "PRAGMA database_list; ", callback, &data, &zErrMsg); if( zErrMsg ){ fprintf(stderr,"Error: %s\n", zErrMsg); | | | 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | data.mode = MODE_Column; data.colWidth[0] = 3; data.colWidth[1] = 15; data.colWidth[2] = 58; sqlite3_exec(p->db, "PRAGMA database_list; ", callback, &data, &zErrMsg); if( zErrMsg ){ fprintf(stderr,"Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); } }else if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){ char *zErrMsg = 0; open_db(p); fprintf(p->out, "BEGIN TRANSACTION;\n"); |
︙ | ︙ | |||
600 601 602 603 604 605 606 | "ORDER BY substr(type,2,1), name", dump_callback, p, &zErrMsg, azArg[i] ); } } if( zErrMsg ){ fprintf(stderr,"Error: %s\n", zErrMsg); | | | 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 | "ORDER BY substr(type,2,1), name", dump_callback, p, &zErrMsg, azArg[i] ); } } if( zErrMsg ){ fprintf(stderr,"Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); }else{ fprintf(p->out, "COMMIT;\n"); } }else if( c=='e' && strncmp(azArg[0], "echo", n)==0 && nArg>1 ){ int j; |
︙ | ︙ | |||
706 707 708 709 710 711 712 | "SELECT name FROM sqlite_temp_master " "WHERE type='index' AND tbl_name LIKE '%q' " "ORDER BY 1", callback, &data, &zErrMsg, azArg[1], azArg[1] ); if( zErrMsg ){ fprintf(stderr,"Error: %s\n", zErrMsg); | | | 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 | "SELECT name FROM sqlite_temp_master " "WHERE type='index' AND tbl_name LIKE '%q' " "ORDER BY 1", callback, &data, &zErrMsg, azArg[1], azArg[1] ); if( zErrMsg ){ fprintf(stderr,"Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); } }else if( c=='m' && strncmp(azArg[0], "mode", n)==0 && nArg>=2 ){ int n2 = strlen(azArg[1]); if( strncmp(azArg[1],"line",n2)==0 || |
︙ | ︙ | |||
790 791 792 793 794 795 796 | char *zOld = p->zKey; if( zOld==0 ) zOld = ""; if( strcmp(azArg[1],zOld) ){ fprintf(stderr,"old key is incorrect\n"); }else if( strcmp(azArg[2], azArg[3]) ){ fprintf(stderr,"2nd copy of new key does not match the 1st\n"); }else{ | | | 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 | char *zOld = p->zKey; if( zOld==0 ) zOld = ""; if( strcmp(azArg[1],zOld) ){ fprintf(stderr,"old key is incorrect\n"); }else if( strcmp(azArg[2], azArg[3]) ){ fprintf(stderr,"2nd copy of new key does not match the 1st\n"); }else{ sqlite3_free(p->zKey); p->zKey = sqlite3_mprintf("%s", azArg[2]); sqlite_rekey(p->db, p->zKey, strlen(p->zKey)); } }else #endif if( c=='s' && strncmp(azArg[0], "schema", n)==0 ){ |
︙ | ︙ | |||
853 854 855 856 857 858 859 | "WHERE type!='meta' AND sql NOTNULL " "ORDER BY substr(type,2,1), name", callback, &data, &zErrMsg ); } if( zErrMsg ){ fprintf(stderr,"Error: %s\n", zErrMsg); | | | 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 | "WHERE type!='meta' AND sql NOTNULL " "ORDER BY substr(type,2,1), name", callback, &data, &zErrMsg ); } if( zErrMsg ){ fprintf(stderr,"Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); } }else if( c=='s' && strncmp(azArg[0], "separator", n)==0 && nArg==2 ){ sprintf(p->separator, "%.*s", (int)ArraySize(p->separator)-1, azArg[1]); }else |
︙ | ︙ | |||
906 907 908 909 910 911 912 | "WHERE type IN ('table','view') AND name LIKE '%%%q%%' " "ORDER BY 1", &azResult, &nRow, 0, &zErrMsg, azArg[1], azArg[1] ); } if( zErrMsg ){ fprintf(stderr,"Error: %s\n", zErrMsg); | | | 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 | "WHERE type IN ('table','view') AND name LIKE '%%%q%%' " "ORDER BY 1", &azResult, &nRow, 0, &zErrMsg, azArg[1], azArg[1] ); } if( zErrMsg ){ fprintf(stderr,"Error: %s\n", zErrMsg); sqlite3_free(zErrMsg); } if( rc==SQLITE_OK ){ int len, maxlen = 0; int i, j; int nPrintCol, nPrintRow; for(i=1; i<=nRow; i++){ if( azResult[i]==0 ) continue; |
︙ | ︙ | |||
1056 1057 1058 1059 1060 1061 1062 | p->cnt = 0; open_db(p); rc = sqlite3_exec(p->db, zSql, callback, p, &zErrMsg); if( rc || zErrMsg ){ if( in!=0 && !p->echoOn ) printf("%s\n",zSql); if( zErrMsg!=0 ){ printf("SQL error: %s\n", zErrMsg); | | | 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 | p->cnt = 0; open_db(p); rc = sqlite3_exec(p->db, zSql, callback, p, &zErrMsg); if( rc || zErrMsg ){ if( in!=0 && !p->echoOn ) printf("%s\n",zSql); if( zErrMsg!=0 ){ printf("SQL error: %s\n", zErrMsg); sqlite3_free(zErrMsg); zErrMsg = 0; }else{ printf("SQL error: %s\n", sqlite3_error_string(rc)); } } free(zSql); zSql = 0; |
︙ | ︙ |
Changes to src/sqlite.h.in.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the SQLite library ** presents to client programs. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This header file defines the interface that the SQLite library ** presents to client programs. ** ** @(#) $Id: sqlite.h.in,v 1.87 2004/05/31 19:34:33 drh Exp $ */ #ifndef _SQLITE_H_ #define _SQLITE_H_ #include <stdarg.h> /* Needed for the definition of va_list */ /* ** Make sure we can call this stuff from C++. |
︙ | ︙ | |||
97 98 99 100 101 102 103 | ** will be invoked. ** ** If an error occurs while parsing or evaluating the SQL (but ** not while executing the callback) then an appropriate error ** message is written into memory obtained from malloc() and ** *errmsg is made to point to that message. The calling function ** is responsible for freeing the memory that holds the error | | | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | ** will be invoked. ** ** If an error occurs while parsing or evaluating the SQL (but ** not while executing the callback) then an appropriate error ** message is written into memory obtained from malloc() and ** *errmsg is made to point to that message. The calling function ** is responsible for freeing the memory that holds the error ** message. Use sqlite3_free() for this. If errmsg==NULL, ** then no error message is ever written. ** ** The return value is is SQLITE_OK if there are no errors and ** some other return code if there is an error. The particular ** return value depends on the type of error. ** ** If the query could not be executed because a database file is |
︙ | ︙ | |||
373 374 375 376 377 378 379 | ** should always use %q instead of %s when inserting text into a string ** literal. */ char *sqlite3_mprintf(const char*,...); char *sqlite3_vmprintf(const char*, va_list); void sqlite3_free(char *z); | < < | 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | ** should always use %q instead of %s when inserting text into a string ** literal. */ char *sqlite3_mprintf(const char*,...); char *sqlite3_vmprintf(const char*, va_list); void sqlite3_free(char *z); /* ** Windows systems need functions to call to return the sqlite3_version ** and sqlite3_encoding strings. */ const char *sqlite3_libversion(void); const char *sqlite3_libencoding(void); |
︙ | ︙ |
Changes to src/test1.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the printf() interface to SQLite. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** ** $Id: test1.c,v 1.67 2004/05/31 19:34:33 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
510 511 512 513 514 515 516 | return TCL_ERROR; } for(i=2; i<5; i++){ if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR; } z = sqlite3_mprintf(argv[1], a[0], a[1], a[2]); Tcl_AppendResult(interp, z, 0); | | | 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 | return TCL_ERROR; } for(i=2; i<5; i++){ if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR; } z = sqlite3_mprintf(argv[1], a[0], a[1], a[2]); Tcl_AppendResult(interp, z, 0); sqlite3_free(z); return TCL_OK; } /* ** Usage: sqlite3_mprintf_str FORMAT INTEGER INTEGER STRING ** ** Call mprintf with two integer arguments and one string argument |
︙ | ︙ | |||
537 538 539 540 541 542 543 | return TCL_ERROR; } for(i=2; i<4; i++){ if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR; } z = sqlite3_mprintf(argv[1], a[0], a[1], argc>4 ? argv[4] : NULL); Tcl_AppendResult(interp, z, 0); | | | 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | return TCL_ERROR; } for(i=2; i<4; i++){ if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR; } z = sqlite3_mprintf(argv[1], a[0], a[1], argc>4 ? argv[4] : NULL); Tcl_AppendResult(interp, z, 0); sqlite3_free(z); return TCL_OK; } /* ** Usage: sqlite3_mprintf_str FORMAT INTEGER INTEGER DOUBLE ** ** Call mprintf with two integer arguments and one double argument |
︙ | ︙ | |||
566 567 568 569 570 571 572 | } for(i=2; i<4; i++){ if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR; } if( Tcl_GetDouble(interp, argv[4], &r) ) return TCL_ERROR; z = sqlite3_mprintf(argv[1], a[0], a[1], r); Tcl_AppendResult(interp, z, 0); | | | 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 | } for(i=2; i<4; i++){ if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR; } if( Tcl_GetDouble(interp, argv[4], &r) ) return TCL_ERROR; z = sqlite3_mprintf(argv[1], a[0], a[1], r); Tcl_AppendResult(interp, z, 0); sqlite3_free(z); return TCL_OK; } /* ** Usage: sqlite3_mprintf_str FORMAT DOUBLE DOUBLE ** ** Call mprintf with a single double argument which is the product of the |
︙ | ︙ | |||
596 597 598 599 600 601 602 | return TCL_ERROR; } for(i=2; i<4; i++){ if( Tcl_GetDouble(interp, argv[i], &r[i-2]) ) return TCL_ERROR; } z = sqlite3_mprintf(argv[1], r[0]*r[1]); Tcl_AppendResult(interp, z, 0); | | | 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | return TCL_ERROR; } for(i=2; i<4; i++){ if( Tcl_GetDouble(interp, argv[i], &r[i-2]) ) return TCL_ERROR; } z = sqlite3_mprintf(argv[1], r[0]*r[1]); Tcl_AppendResult(interp, z, 0); sqlite3_free(z); return TCL_OK; } /* ** Usage: sqlite_malloc_fail N ** ** Rig sqliteMalloc() to fail on the N-th call. Turn off this mechanism |
︙ | ︙ |
Changes to src/test4.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* ** 2003 December 18 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the the SQLite library in a multithreaded environment. ** | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* ** 2003 December 18 ** ** The author disclaims copyright to this source code. In place of ** a legal notice, here is a blessing: ** ** May you do good and not evil. ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** Code for testing the the SQLite library in a multithreaded environment. ** ** $Id: test4.c,v 1.9 2004/05/31 19:34:33 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" #include "os.h" #if defined(OS_UNIX) && OS_UNIX==1 && defined(THREADSAFE) && THREADSAFE==1 #include <stdlib.h> #include <string.h> |
︙ | ︙ | |||
73 74 75 76 77 78 79 | p->db = 0; } p->pStmt = 0; p->completed = 1; while( p->opnum<=p->completed ) sched_yield(); while( p->xOp ){ if( p->zErr && p->zErr!=p->zStaticErr ){ | | | | 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | p->db = 0; } p->pStmt = 0; p->completed = 1; while( p->opnum<=p->completed ) sched_yield(); while( p->xOp ){ if( p->zErr && p->zErr!=p->zStaticErr ){ sqlite3_free(p->zErr); p->zErr = 0; } (*p->xOp)(p); p->completed++; while( p->opnum<=p->completed ) sched_yield(); } if( p->pStmt ){ sqlite3_finalize(p->pStmt); p->pStmt = 0; } if( p->db ){ sqlite3_close(p->db); p->db = 0; } if( p->zErr && p->zErr!=p->zStaticErr ){ sqlite3_free(p->zErr); p->zErr = 0; } p->completed++; return 0; } /* |
︙ | ︙ |