diff options
| author | Ilia Alshanetsky <iliaa@php.net> | 2006-08-14 16:15:29 +0000 |
|---|---|---|
| committer | Ilia Alshanetsky <iliaa@php.net> | 2006-08-14 16:15:29 +0000 |
| commit | e8f30d450255baa92c1f2abe5d4a2696b6e4ebf0 (patch) | |
| tree | 1ededffa0df99ad1b61a3e476febad54b6a15991 /ext/pdo_sqlite/sqlite/src/os_common.h | |
| parent | 0091c7e1b337de1252824ec33c87b4bed9ca2a5c (diff) | |
| download | php-git-e8f30d450255baa92c1f2abe5d4a2696b6e4ebf0.tar.gz | |
Upgraded bunbled SQLite lib to 3.3.7
Diffstat (limited to 'ext/pdo_sqlite/sqlite/src/os_common.h')
| -rw-r--r-- | ext/pdo_sqlite/sqlite/src/os_common.h | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/ext/pdo_sqlite/sqlite/src/os_common.h b/ext/pdo_sqlite/sqlite/src/os_common.h index b19ff05906..d65c352ddf 100644 --- a/ext/pdo_sqlite/sqlite/src/os_common.h +++ b/ext/pdo_sqlite/sqlite/src/os_common.h @@ -88,6 +88,7 @@ static unsigned int elapse; ** is used for testing the I/O recovery logic. */ #ifdef SQLITE_TEST +int sqlite3_io_error_hit = 0; int sqlite3_io_error_pending = 0; int sqlite3_diskfull_pending = 0; int sqlite3_diskfull = 0; @@ -95,7 +96,7 @@ int sqlite3_diskfull = 0; if( sqlite3_io_error_pending ) \ if( sqlite3_io_error_pending-- == 1 ){ local_ioerr(); return A; } static void local_ioerr(){ - sqlite3_io_error_pending = 0; /* Really just a place to set a breakpoint */ + sqlite3_io_error_hit = 1; /* Really just a place to set a breakpoint */ } #define SimulateDiskfullError \ if( sqlite3_diskfull_pending ){ \ @@ -121,3 +122,67 @@ int sqlite3_open_file_count = 0; #else #define OpenCounter(X) #endif + +/* +** sqlite3GenericMalloc +** sqlite3GenericRealloc +** sqlite3GenericOsFree +** sqlite3GenericAllocationSize +** +** Implementation of the os level dynamic memory allocation interface in terms +** of the standard malloc(), realloc() and free() found in many operating +** systems. No rocket science here. +** +** There are two versions of these four functions here. The version +** implemented here is only used if memory-management or memory-debugging is +** enabled. This version allocates an extra 8-bytes at the beginning of each +** block and stores the size of the allocation there. +** +** If neither memory-management or debugging is enabled, the second +** set of implementations is used instead. +*/ +#if defined(SQLITE_ENABLE_MEMORY_MANAGEMENT) || defined (SQLITE_MEMDEBUG) +void *sqlite3GenericMalloc(int n){ + char *p = (char *)malloc(n+8); + assert(n>0); + assert(sizeof(int)<=8); + if( p ){ + *(int *)p = n; + p += 8; + } + return (void *)p; +} +void *sqlite3GenericRealloc(void *p, int n){ + char *p2 = ((char *)p - 8); + assert(n>0); + p2 = (char*)realloc(p2, n+8); + if( p2 ){ + *(int *)p2 = n; + p2 += 8; + } + return (void *)p2; +} +void sqlite3GenericFree(void *p){ + assert(p); + free((void *)((char *)p - 8)); +} +int sqlite3GenericAllocationSize(void *p){ + return p ? *(int *)((char *)p - 8) : 0; +} +#else +void *sqlite3GenericMalloc(int n){ + char *p = (char *)malloc(n); + return (void *)p; +} +void *sqlite3GenericRealloc(void *p, int n){ + assert(n>0); + p = realloc(p, n); + return p; +} +void sqlite3GenericFree(void *p){ + assert(p); + free(p); +} +/* Never actually used, but needed for the linker */ +int sqlite3GenericAllocationSize(void *p){ return 0; } +#endif |
