Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: third_party/sqlite/sqlite-src-3080704/src/test_init.c

Issue 883353008: [sql] Import reference version of SQLite 3.8.7.4. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Hold back encoding change which is messing up patch. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 ** 2009 August 17 2 ** 2009 August 17
3 ** 3 **
4 ** The author disclaims copyright to this source code. In place of 4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing: 5 ** a legal notice, here is a blessing:
6 ** 6 **
7 ** May you do good and not evil. 7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others. 8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give. 9 ** May you share freely, never taking more than you give.
10 ** 10 **
(...skipping 12 matching lines...) Expand all
23 ** of those subsystems that were initialized, and 23 ** of those subsystems that were initialized, and
24 ** 3) A subsequent call to sqlite3_initialize() attempts to initialize 24 ** 3) A subsequent call to sqlite3_initialize() attempts to initialize
25 ** the remaining, uninitialized, subsystems. 25 ** the remaining, uninitialized, subsystems.
26 */ 26 */
27 27
28 #include "sqliteInt.h" 28 #include "sqliteInt.h"
29 #include <string.h> 29 #include <string.h>
30 #include <tcl.h> 30 #include <tcl.h>
31 31
32 static struct Wrapped { 32 static struct Wrapped {
33 sqlite3_pcache_methods pcache; 33 sqlite3_pcache_methods2 pcache;
34 sqlite3_mem_methods mem; 34 sqlite3_mem_methods mem;
35 sqlite3_mutex_methods mutex; 35 sqlite3_mutex_methods mutex;
36 36
37 int mem_init; /* True if mem subsystem is initalized */ 37 int mem_init; /* True if mem subsystem is initalized */
38 int mem_fail; /* True to fail mem subsystem inialization */ 38 int mem_fail; /* True to fail mem subsystem inialization */
39 int mutex_init; /* True if mutex subsystem is initalized */ 39 int mutex_init; /* True if mutex subsystem is initalized */
40 int mutex_fail; /* True to fail mutex subsystem inialization */ 40 int mutex_fail; /* True to fail mutex subsystem inialization */
41 int pcache_init; /* True if pcache subsystem is initalized */ 41 int pcache_init; /* True if pcache subsystem is initalized */
42 int pcache_fail; /* True to fail pcache subsystem inialization */ 42 int pcache_fail; /* True to fail pcache subsystem inialization */
43 } wrapped; 43 } wrapped;
44 44
45 static int wrMemInit(void *pAppData){ 45 static int wrMemInit(void *pAppData){
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 if( rc==SQLITE_OK ){ 116 if( rc==SQLITE_OK ){
117 wrapped.pcache_init = 1; 117 wrapped.pcache_init = 1;
118 } 118 }
119 return rc; 119 return rc;
120 } 120 }
121 static void wrPCacheShutdown(void *pArg){ 121 static void wrPCacheShutdown(void *pArg){
122 wrapped.pcache.xShutdown(wrapped.pcache.pArg); 122 wrapped.pcache.xShutdown(wrapped.pcache.pArg);
123 wrapped.pcache_init = 0; 123 wrapped.pcache_init = 0;
124 } 124 }
125 125
126 static sqlite3_pcache *wrPCacheCreate(int a, int b){ 126 static sqlite3_pcache *wrPCacheCreate(int a, int b, int c){
127 return wrapped.pcache.xCreate(a, b); 127 return wrapped.pcache.xCreate(a, b, c);
128 } 128 }
129 static void wrPCacheCachesize(sqlite3_pcache *p, int n){ 129 static void wrPCacheCachesize(sqlite3_pcache *p, int n){
130 wrapped.pcache.xCachesize(p, n); 130 wrapped.pcache.xCachesize(p, n);
131 } 131 }
132 static int wrPCachePagecount(sqlite3_pcache *p){ 132 static int wrPCachePagecount(sqlite3_pcache *p){
133 return wrapped.pcache.xPagecount(p); 133 return wrapped.pcache.xPagecount(p);
134 } 134 }
135 static void *wrPCacheFetch(sqlite3_pcache *p, unsigned a, int b){ 135 static sqlite3_pcache_page *wrPCacheFetch(sqlite3_pcache *p, unsigned a, int b){
136 return wrapped.pcache.xFetch(p, a, b); 136 return wrapped.pcache.xFetch(p, a, b);
137 } 137 }
138 static void wrPCacheUnpin(sqlite3_pcache *p, void *a, int b){ 138 static void wrPCacheUnpin(sqlite3_pcache *p, sqlite3_pcache_page *a, int b){
139 wrapped.pcache.xUnpin(p, a, b); 139 wrapped.pcache.xUnpin(p, a, b);
140 } 140 }
141 static void wrPCacheRekey(sqlite3_pcache *p, void *a, unsigned b, unsigned c){ 141 static void wrPCacheRekey(
142 sqlite3_pcache *p,
143 sqlite3_pcache_page *a,
144 unsigned b,
145 unsigned c
146 ){
142 wrapped.pcache.xRekey(p, a, b, c); 147 wrapped.pcache.xRekey(p, a, b, c);
143 } 148 }
144 static void wrPCacheTruncate(sqlite3_pcache *p, unsigned a){ 149 static void wrPCacheTruncate(sqlite3_pcache *p, unsigned a){
145 wrapped.pcache.xTruncate(p, a); 150 wrapped.pcache.xTruncate(p, a);
146 } 151 }
147 static void wrPCacheDestroy(sqlite3_pcache *p){ 152 static void wrPCacheDestroy(sqlite3_pcache *p){
148 wrapped.pcache.xDestroy(p); 153 wrapped.pcache.xDestroy(p);
149 } 154 }
150 155
151 static void installInitWrappers(void){ 156 static void installInitWrappers(void){
152 sqlite3_mutex_methods mutexmethods = { 157 sqlite3_mutex_methods mutexmethods = {
153 wrMutexInit, wrMutexEnd, wrMutexAlloc, 158 wrMutexInit, wrMutexEnd, wrMutexAlloc,
154 wrMutexFree, wrMutexEnter, wrMutexTry, 159 wrMutexFree, wrMutexEnter, wrMutexTry,
155 wrMutexLeave, wrMutexHeld, wrMutexNotheld 160 wrMutexLeave, wrMutexHeld, wrMutexNotheld
156 }; 161 };
157 sqlite3_pcache_methods pcachemethods = { 162 sqlite3_pcache_methods2 pcachemethods = {
158 0, 163 1, 0,
159 wrPCacheInit, wrPCacheShutdown, wrPCacheCreate, 164 wrPCacheInit, wrPCacheShutdown, wrPCacheCreate,
160 wrPCacheCachesize, wrPCachePagecount, wrPCacheFetch, 165 wrPCacheCachesize, wrPCachePagecount, wrPCacheFetch,
161 wrPCacheUnpin, wrPCacheRekey, wrPCacheTruncate, 166 wrPCacheUnpin, wrPCacheRekey, wrPCacheTruncate,
162 wrPCacheDestroy 167 wrPCacheDestroy
163 }; 168 };
164 sqlite3_mem_methods memmethods = { 169 sqlite3_mem_methods memmethods = {
165 wrMemMalloc, wrMemFree, wrMemRealloc, 170 wrMemMalloc, wrMemFree, wrMemRealloc,
166 wrMemSize, wrMemRoundup, wrMemInit, 171 wrMemSize, wrMemRoundup, wrMemInit,
167 wrMemShutdown, 172 wrMemShutdown,
168 0 173 0
169 }; 174 };
170 175
171 memset(&wrapped, 0, sizeof(wrapped)); 176 memset(&wrapped, 0, sizeof(wrapped));
172 177
173 sqlite3_shutdown(); 178 sqlite3_shutdown();
174 sqlite3_config(SQLITE_CONFIG_GETMUTEX, &wrapped.mutex); 179 sqlite3_config(SQLITE_CONFIG_GETMUTEX, &wrapped.mutex);
175 sqlite3_config(SQLITE_CONFIG_GETMALLOC, &wrapped.mem); 180 sqlite3_config(SQLITE_CONFIG_GETMALLOC, &wrapped.mem);
176 sqlite3_config(SQLITE_CONFIG_GETPCACHE, &wrapped.pcache); 181 sqlite3_config(SQLITE_CONFIG_GETPCACHE2, &wrapped.pcache);
177 sqlite3_config(SQLITE_CONFIG_MUTEX, &mutexmethods); 182 sqlite3_config(SQLITE_CONFIG_MUTEX, &mutexmethods);
178 sqlite3_config(SQLITE_CONFIG_MALLOC, &memmethods); 183 sqlite3_config(SQLITE_CONFIG_MALLOC, &memmethods);
179 sqlite3_config(SQLITE_CONFIG_PCACHE, &pcachemethods); 184 sqlite3_config(SQLITE_CONFIG_PCACHE2, &pcachemethods);
180 } 185 }
181 186
182 static int init_wrapper_install( 187 static int init_wrapper_install(
183 ClientData clientData, /* Unused */ 188 ClientData clientData, /* Unused */
184 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ 189 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
185 int objc, /* Number of arguments */ 190 int objc, /* Number of arguments */
186 Tcl_Obj *CONST objv[] /* Command arguments */ 191 Tcl_Obj *CONST objv[] /* Command arguments */
187 ){ 192 ){
188 int i; 193 int i;
189 installInitWrappers(); 194 installInitWrappers();
(...skipping 17 matching lines...) Expand all
207 ClientData clientData, /* Unused */ 212 ClientData clientData, /* Unused */
208 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ 213 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
209 int objc, /* Number of arguments */ 214 int objc, /* Number of arguments */
210 Tcl_Obj *CONST objv[] /* Command arguments */ 215 Tcl_Obj *CONST objv[] /* Command arguments */
211 ){ 216 ){
212 if( objc!=1 ){ 217 if( objc!=1 ){
213 Tcl_WrongNumArgs(interp, 1, objv, ""); 218 Tcl_WrongNumArgs(interp, 1, objv, "");
214 return TCL_ERROR; 219 return TCL_ERROR;
215 } 220 }
216 221
217 memset(&wrapped, 0, sizeof(&wrapped));
218 sqlite3_shutdown(); 222 sqlite3_shutdown();
219 sqlite3_config(SQLITE_CONFIG_MUTEX, &wrapped.mutex); 223 sqlite3_config(SQLITE_CONFIG_MUTEX, &wrapped.mutex);
220 sqlite3_config(SQLITE_CONFIG_MALLOC, &wrapped.mem); 224 sqlite3_config(SQLITE_CONFIG_MALLOC, &wrapped.mem);
221 sqlite3_config(SQLITE_CONFIG_PCACHE, &wrapped.pcache); 225 sqlite3_config(SQLITE_CONFIG_PCACHE2, &wrapped.pcache);
222 return TCL_OK; 226 return TCL_OK;
223 } 227 }
224 228
225 static int init_wrapper_clear( 229 static int init_wrapper_clear(
226 ClientData clientData, /* Unused */ 230 ClientData clientData, /* Unused */
227 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */ 231 Tcl_Interp *interp, /* The TCL interpreter that invoked this command */
228 int objc, /* Number of arguments */ 232 int objc, /* Number of arguments */
229 Tcl_Obj *CONST objv[] /* Command arguments */ 233 Tcl_Obj *CONST objv[] /* Command arguments */
230 ){ 234 ){
231 if( objc!=1 ){ 235 if( objc!=1 ){
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 {"init_wrapper_clear", init_wrapper_clear} 282 {"init_wrapper_clear", init_wrapper_clear}
279 }; 283 };
280 int i; 284 int i;
281 285
282 for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){ 286 for(i=0; i<sizeof(aObjCmd)/sizeof(aObjCmd[0]); i++){
283 Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0); 287 Tcl_CreateObjCommand(interp, aObjCmd[i].zName, aObjCmd[i].xProc, 0, 0);
284 } 288 }
285 289
286 return TCL_OK; 290 return TCL_OK;
287 } 291 }
OLDNEW
« no previous file with comments | « third_party/sqlite/sqlite-src-3080704/src/test_hexio.c ('k') | third_party/sqlite/sqlite-src-3080704/src/test_intarray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698