Patch level : 4.0 622

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :

Prova ottimizzazioni di conversioni


git-svn-id: svn://10.65.10.50/trunk@14907 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2007-02-13 12:01:54 +00:00
parent 62ccd80780
commit 221c0b2a65

View File

@ -40,7 +40,8 @@ static DATA4 *dbdata[CB4FILES];
bool handle_ok(int handle) bool handle_ok(int handle)
{ {
return handle >= 0 && handle < CB4FILES && dbdata[handle] != NULL; return handle >= 0 && handle < CB4FILES &&
dbdata[handle] != NULL && dbdata[handle]->clientId >= 0;
} }
static char* find_slash_backslash(const char* s) static char* find_slash_backslash(const char* s)
@ -62,17 +63,16 @@ static char* find_slash_backslash(const char* s)
--------------------------------------------------------------------------*/ --------------------------------------------------------------------------*/
void DB_init(void) void DB_init(void)
{ {
int i; memset(dbdata, 0, sizeof(dbdata));
for(i=0;i<CB4FILES;i++)
dbdata[i]=(DATA4*)NULL;
code4init(&code_base); code4init(&code_base);
code_base.readLock=0; code_base.readLock=0;
code_base.errDefaultUnique=e4unique; code_base.errDefaultUnique=e4unique;
code_base.safety=0; code_base.safety=0;
code_base.lockAttempts=1; code_base.lockAttempts=1;
// code_base.optimize_write = 0;
code4dateFormatSet(&code_base, "CCYYMMDD"); code4dateFormatSet(&code_base, "CCYYMMDD");
code_base.optimizeWrite = OPT4EXCLUSIVE; // Is the default?
} }
/*-------------------------------------------------------------------------- /*--------------------------------------------------------------------------
@ -84,13 +84,12 @@ void DB_init(void)
void DB_exit(void) void DB_exit(void)
{ {
int i; int i;
code4initUndo(&code_base); for(i=0; i< CB4FILES; i++)
for(i=0;i<CB4FILES;i++)
{ {
if (handle_ok(i)) if (handle_ok(i))
DB_close(i); DB_close(i);
} }
code4initUndo(&code_base);
} }
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
@ -100,8 +99,8 @@ void DB_exit(void)
int DB_open(const char *filename,int mode,int index) int DB_open(const char *filename,int mode,int index)
{ {
int i,found; int i,found;
if (mode)
if (mode) code_base.accessMode=1; code_base.accessMode=1; // Exclusive mode
/* cerca il primo posto libero nel vettore dbdata */ /* cerca il primo posto libero nel vettore dbdata */
found=-1; found=-1;
for(i=0;i<CB4FILES;i++) for(i=0;i<CB4FILES;i++)
@ -113,7 +112,9 @@ int DB_open(const char *filename,int mode,int index)
} }
} }
/* se non ci sono posti liberi torna -1 */ /* se non ci sono posti liberi torna -1 */
if(found==-1) return(found); if(found==-1)
return(found);
code_base.errorCode=0; code_base.errorCode=0;
if (index == 0) /* Se e' stata richiesta l'apertura senza indici, setta il flag */ if (index == 0) /* Se e' stata richiesta l'apertura senza indici, setta il flag */
code_base.autoOpen = 0; code_base.autoOpen = 0;
@ -399,8 +400,9 @@ int DB_rewrite(int handle)
u4delaySec(); u4delaySec();
if (rt == 0) if (rt == 0)
{ {
while ((rt = d4flush(dbdata[handle])) == r4locked) /* while ((rt = d4flush(dbdata[handle])) == r4locked)
u4delaySec(); u4delaySec(); */
rt = DB_flush(handle);
} }
if (rt == e4unique) if (rt == e4unique)
{ {
@ -454,7 +456,7 @@ int DB_add(int handle)
rt = _isreinsert; rt = _isreinsert;
} }
else else
if (rt == 0) if (rt == 0 && is_locked == 0)
{ {
while ((rt = d4flush(data)) == r4locked) while ((rt = d4flush(data)) == r4locked)
u4delaySec(); u4delaySec();
@ -1154,20 +1156,20 @@ long DB_changed(int handle)
char* DB_memoptr( const int handle, const char * fieldname ) char* DB_memoptr( const int handle, const char * fieldname )
{ {
FIELD4 * f; FIELD4* f = d4field( dbdata[ handle ], ( char *)fieldname );
f = d4field( dbdata[ handle ], ( char *)fieldname );
return f4memoPtr( f ); return f4memoPtr( f );
} }
int DB_memowrite( const int handle, const char * fieldname, const char * data ) int DB_memowrite( const int handle, const char * fieldname, const char * data )
{ {
int ret; FIELD4* f = d4field(dbdata[handle], fieldname );
FIELD4 * f; int ret = f4memoAssign( f, (char*)data );
f = d4field(dbdata[handle], fieldname );
ret = f4memoAssign( f, ( char * )data );
d4flush(dbdata[handle]);
if (ret == 0 && !DB_file_locked(handle))
{
d4flush(dbdata[handle]);
d4unlock(dbdata[handle]); d4unlock(dbdata[handle]);
}
return ret; return ret;
} }