http://spserver.googlecode.com/files/spmemvfs-0.1.src.tar.gz
Changes: * Modify the save callback, transfer the ownership of the buffer to callback function * Add a buffer map to pass buffer between application and sqlite3 vfs The demo code: static void * load( void * arg, const char * path, int * len ) { spmembuffer_map_t * themap = (spmembuffer_map_t*)arg; char * ret = spmembuffer_map_take( themap, path, len ); return ret; } static int save( void * arg, const char * path, char * buffer, int len ) { spmembuffer_map_t * themap = (spmembuffer_map_t*)arg; return spmembuffer_map_put( themap, path, buffer, len ); } int main( int argc, char * argv[] ) { spmembuffer_map_t * themap = spmembuffer_map_new(); spmemvfs_cb_t cb = { themap, load, save }; const char * path = "abc.db"; spmemvfs_init( &cb ); // load membuffer from file, put it into themap { char * buffer = NULL; int len = 0; buffer = read_buffer_from_file( path, &len ); spmembuffer_map_put( themap, path, buffer, len ); } // open sqlite by sqlite3_open_v2 { sqlite3 * dbHandle = NULL; char errcode = sqlite3_open_v2( path, &dbHandle, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, SPMEMVFS_NAME ); // do wahtever you want ...... } // get membuffer from themap, save it to file { int len = 0; char * buffer = (char*)spmembuffer_map_take( themap, path, &len ); save_buffer_to_file( path, buffer, len ); free( buffer ); } spmembuffer_map_del( themap ); return 0; } _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users