-C Add\sthe\ssqlite3_os_routine_set()/get()\sfunctions.\s(CVS\s2818)
-D 2005-12-15T10:11:31
+C Move\smalloc(),\sfree(),\srealloc()\sand\sallocationSize()\sinto\sthe\sOs\svtbl.\s(CVS\s2819)
+D 2005-12-15T10:50:54
F Makefile.in e3c6b3a38d734d41574c04f2fc90d18de2b87102
F Makefile.linux-gcc aee18d8a05546dcf1888bd4547e442008a49a092
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
F src/main.c a12aa72335036bb22249418e222124abfc581b85
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
F src/os.c 7b4a002d9c9421580276db55d2329636a604e8ef
-F src/os.h df6babd4fd74bb659470c31fa5a27de31b1c474e
-F src/os_common.h d74a11728ad2444b6b695b94c28c06881f049e49
+F src/os.h e941992043b127fdb1bd114f0b4319ae1c4562a7
+F src/os_common.h a4ad0448f112bb124e5df9eb41c377e770aee7b2
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
-F src/os_unix.c df6e4972099aa5263183009fb947083633236dd3
+F src/os_unix.c 6394d2fa3a8bfbceb227579b44b4b343b5b54a8f
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
-F src/os_win.c 2da77ddc03de8c51688cca648ced766b5dad8a6a
+F src/os_win.c 9feb97f49b93d451f8ef7c5dd388e05a44647dc6
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
F src/pager.c 49f63a54b57164a70df0b1539141003fd27856c6
F src/pager.h e7b41ce8e7b5f629d456708b7ad9a8c8ede37140
F src/trigger.c 2925ba96d964d9b717e74006bf7e64b8a6b70d97
F src/update.c ec8e540617b116725b5a55c8d6b4db8bc67fdd7d
F src/utf.c d2360f55ecd666f3e472738191f8dae717b95e5e
-F src/util.c 06ab728430ae55191076cdf4075be36f621a7183
+F src/util.c 8bb5e0553692d36c769d6cd033eb7f68a7586648
F src/vacuum.c fbfdd3967fd34e2f260fafed88dcbf3c10856b94
F src/vdbe.c d09c185f4badac6c79f2a919cbf661e7b5618293
F src/vdbe.h 8729a4ee16ff9aeab2af9667df3cf300ff978e13
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl a99cf5f6d8bd4d5537584a2b342f0fb9fa601d8b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
-P ad292e27336b8c5afc0acdf111944a456bd23c32
-R 079783b8421fc6a8eada9a4aa8fe00c7
+P c1ed79f594fb85009c2e9e5e281cbe66a9d2fa17
+R e31df3de6303938f8025bb0d1c87c829
U danielk1977
-Z 21e315959d3bb7c348f1a6f926708fc0
+Z d08eb08fd8a87ac6ccdc5f99bd5ce249
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
-** $Id: util.c,v 1.153 2005/12/15 10:11:32 danielk1977 Exp $
+** $Id: util.c,v 1.154 2005/12/15 10:50:54 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "os.h"
** level (not in this file). The Os level interface is never accessed directly
** by code outside of this file.
**
-** sqlite3OsMalloc()
-** sqlite3OsRealloc()
-** sqlite3OsFree()
-** sqlite3OsAllocationSize()
+** sqlite3Os.xMalloc()
+** sqlite3Os.xRealloc()
+** sqlite3Os.xFree()
+** sqlite3Os.xAllocationSize()
**
** Functions sqlite3MallocRaw() and sqlite3Realloc() may invoke
-** sqlite3_release_memory() if a call to sqlite3OsMalloc() or
-** sqlite3OsRealloc() fails. Function sqlite3Malloc() usually invokes
+** sqlite3_release_memory() if a call to sqlite3Os.xMalloc() or
+** sqlite3Os.xRealloc() fails. Function sqlite3Malloc() usually invokes
** sqlite3MallocRaw().
**
** MALLOC TEST WRAPPER ARCHITECTURE
** * Audit outstanding memory allocations (i.e check for leaks).
*/
-/*
-** sqlite3OsMalloc
-** sqlite3OsRealloc
-** sqlite3OsOsFree
-** sqlite3OsAllocationSize
-**
-** 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.
-*/
-void *sqlite3OsMalloc(int n){
- char *p = (char *)malloc(n+8);
- assert(n>0);
- assert(sizeof(int)<=8);
- if( p ){
- *(int *)p = n;
- }
- return (void *)(p + 8);
-}
-void *sqlite3OsRealloc(void *p, int n){
- char *p2 = ((char *)p - 8);
- assert(n>0);
- p2 = realloc(p2, n+8);
- if( p2 ){
- *(int *)p2 = n;
- }
- return (void *)((char *)p2 + 8);
-}
-void sqlite3OsFree(void *p){
- assert(p);
- free((void *)((char *)p - 8));
-}
-int sqlite3OsAllocationSize(void *p){
- return *(int *)((char *)p - 8);
-}
-
/*
** TODO!
*/
TESTALLOC_OFFSET_GUARD1(p) + sizeof(u32) * TESTALLOC_NGUARD \
)
#define TESTALLOC_OFFSET_GUARD2(p) ( \
- TESTALLOC_OFFSET_DATA(p) + sqlite3OsAllocationSize(p) - TESTALLOC_OVERHEAD \
+ TESTALLOC_OFFSET_DATA(p) + sqlite3Os.xAllocationSize(p) - TESTALLOC_OVERHEAD \
)
#define TESTALLOC_OFFSET_LINENUMBER(p) ( \
TESTALLOC_OFFSET_GUARD2(p) + sizeof(u32) * TESTALLOC_NGUARD \
}
/*
-** The argument is a pointer returned by sqlite3OsMalloc() or Realloc().
+** The argument is a pointer returned by sqlite3Os.xMalloc() or xRealloc().
** assert() that the first and last (TESTALLOC_NGUARD*4) bytes are set to the
** values set by the applyGuards() function.
*/
}
/*
-** The argument is a pointer returned by sqlite3OsMalloc() or Realloc(). The
+** The argument is a pointer returned by sqlite3Os.xMalloc() or Realloc(). The
** first and last (TESTALLOC_NGUARD*4) bytes are set to known values for use as
** guard-posts.
*/
Tcl_Obj *pStack = Tcl_NewObj();
char *z;
u32 iLine;
- int nBytes = sqlite3OsAllocationSize(p) - TESTALLOC_OVERHEAD;
+ int nBytes = sqlite3Os.xAllocationSize(p) - TESTALLOC_OVERHEAD;
char *zAlloc = (char *)p;
int i;
#endif
/*
-** This is the test layer's wrapper around sqlite3OsMalloc().
+** This is the test layer's wrapper around sqlite3Os.xMalloc().
*/
static void * OSMALLOC(int n){
if( !failMalloc() ){
u32 *p;
- p = (u32 *)sqlite3OsMalloc(n + TESTALLOC_OVERHEAD);
+ p = (u32 *)sqlite3Os.xMalloc(n + TESTALLOC_OVERHEAD);
assert(p);
sqlite3_nMalloc++;
applyGuards(p);
}
/*
-** This is the test layer's wrapper around sqlite3OsFree(). The argument is a
+** This is the test layer's wrapper around sqlite3Os.xFree(). The argument is a
** pointer to the space allocated for the application to use.
*/
void OSFREE(void *pFree){
u32 *p = (u32 *)getOsPointer(pFree); /* p points to Os level allocation */
checkGuards(p);
unlinkAlloc(p);
- sqlite3OsFree(p);
+ sqlite3Os.xFree(p);
sqlite3_nFree++;
}
/*
-** This is the test layer's wrapper around sqlite3OsRealloc().
+** This is the test layer's wrapper around sqlite3Os.xRealloc().
*/
void * OSREALLOC(void *pRealloc, int n){
if( !failMalloc() ){
u32 *p = (u32 *)getOsPointer(pRealloc);
checkGuards(p);
- p = sqlite3OsRealloc(p, n + TESTALLOC_OVERHEAD);
+ p = sqlite3Os.xRealloc(p, n + TESTALLOC_OVERHEAD);
applyGuards(p);
relinkAlloc(p);
return (void *)(&p[TESTALLOC_NGUARD + 2*sizeof(void *)/sizeof(u32)]);
int OSSIZEOF(void *p){
if( p ){
- return sqlite3OsAllocationSize(p) - TESTALLOC_OVERHEAD;
+ return sqlite3Os.xAllocationSize(p) - TESTALLOC_OVERHEAD;
}
return 0;
}
#else
-#define OSMALLOC(x) sqlite3OsMalloc(x)
-#define OSREALLOC(x,y) sqlite3OsRealloc(x,y)
-#define OSFREE(x) sqlite3OsFree(x)
-#define OSSIZEOF(x) sqlite3OsAllocationSize(x)
+#define OSMALLOC(x) sqlite3Os.xMalloc(x)
+#define OSREALLOC(x,y) sqlite3Os.xRealloc(x,y)
+#define OSFREE(x) sqlite3Os.xFree(x)
+#define OSSIZEOF(x) sqlite3Os.xAllocationSize(x)
#define OSMALLOC_FAILED()
#endif
/*
/*
** The handleSoftLimit() function is called before each call to
-** sqlite3OsMalloc() or sqlite3OsRealloc(). The parameter 'n' is the number of
+** sqlite3Os.xMalloc() or xRealloc(). The parameter 'n' is the number of
** extra bytes about to be allocated (for Realloc() this means the size of the
** new allocation less the size of the old allocation). If the extra allocation
** means that the total memory allocated to SQLite in this thread would exceed
/*
** Allocate and return N bytes of uninitialised memory by calling
-** sqlite3OsMalloc(). If the Malloc() call fails, attempt to free memory
+** sqlite3Os.xMalloc(). If the Malloc() call fails, attempt to free memory
** by calling sqlite3_release_memory().
*/
void *sqlite3MallocRaw(int n){
}
/*
-** Resize the allocation at p to n bytes by calling sqlite3OsRealloc(). The
+** Resize the allocation at p to n bytes by calling sqlite3Os.xRealloc(). The
** pointer to the new allocation is returned. If the Realloc() call fails,
** attempt to free memory by calling sqlite3_release_memory().
*/