Commit 5f1b258c authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Convert the list of tables to a standard list.

parent b5f87893
...@@ -134,15 +134,14 @@ UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb) ...@@ -134,15 +134,14 @@ UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb)
goto end; goto end;
} }
if(( memcmp( &stat.clsid, &CLSID_MsiDatabase, sizeof (GUID) ) ) if ( !IsEqualGUID( &stat.clsid, &CLSID_MsiDatabase ) &&
&& ( memcmp( &stat.clsid, &CLSID_MsiPatch, sizeof (GUID) ) )) !IsEqualGUID( &stat.clsid, &CLSID_MsiPatch ) )
{ {
ERR("storage GUID is not a MSI database GUID %s\n", ERR("storage GUID is not a MSI database GUID %s\n",
debugstr_guid(&stat.clsid) ); debugstr_guid(&stat.clsid) );
goto end; goto end;
} }
db = alloc_msiobject( MSIHANDLETYPE_DATABASE, sizeof (MSIDATABASE), db = alloc_msiobject( MSIHANDLETYPE_DATABASE, sizeof (MSIDATABASE),
MSI_CloseDatabase ); MSI_CloseDatabase );
if( !db ) if( !db )
...@@ -156,6 +155,7 @@ UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb) ...@@ -156,6 +155,7 @@ UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb)
db->storage = stg; db->storage = stg;
db->mode = szMode; db->mode = szMode;
list_init( &db->tables );
ret = load_string_table( db ); ret = load_string_table( db );
if( ret != ERROR_SUCCESS ) if( ret != ERROR_SUCCESS )
......
...@@ -67,7 +67,7 @@ typedef struct tagMSIDATABASE ...@@ -67,7 +67,7 @@ typedef struct tagMSIDATABASE
IStorage *storage; IStorage *storage;
string_table *strings; string_table *strings;
LPCWSTR mode; LPCWSTR mode;
MSITABLE *first_table, *last_table; struct list tables;
} MSIDATABASE; } MSIDATABASE;
typedef struct tagMSIVIEW MSIVIEW; typedef struct tagMSIVIEW MSIVIEW;
......
...@@ -53,8 +53,7 @@ struct tagMSITABLE ...@@ -53,8 +53,7 @@ struct tagMSITABLE
USHORT **data; USHORT **data;
UINT ref_count; UINT ref_count;
UINT row_count; UINT row_count;
struct tagMSITABLE *next; struct list entry;
struct tagMSITABLE *prev;
WCHAR name[1]; WCHAR name[1];
}; };
...@@ -483,28 +482,13 @@ static UINT read_table_from_storage( MSIDATABASE *db, LPCWSTR name, MSITABLE **p ...@@ -483,28 +482,13 @@ static UINT read_table_from_storage( MSIDATABASE *db, LPCWSTR name, MSITABLE **p
/* add this table to the list of cached tables in the database */ /* add this table to the list of cached tables in the database */
void add_table(MSIDATABASE *db, MSITABLE *table) void add_table(MSIDATABASE *db, MSITABLE *table)
{ {
table->next = db->first_table; list_add_head( &db->tables, &table->entry );
table->prev = NULL;
if( db->first_table )
db->first_table->prev = table;
else
db->last_table = table;
db->first_table = table;
} }
/* remove from the list of cached tables */ /* remove from the list of cached tables */
void remove_table( MSIDATABASE *db, MSITABLE *table ) void remove_table( MSIDATABASE *db, MSITABLE *table )
{ {
if( table->next ) list_remove( &table->entry );
table->next->prev = table->prev;
else
db->last_table = table->prev;
if( table->prev )
table->prev->next = table->next;
else
db->first_table = table->next;
table->next = NULL;
table->prev = NULL;
} }
static void release_table( MSIDATABASE *db, MSITABLE *table ) static void release_table( MSIDATABASE *db, MSITABLE *table )
...@@ -523,10 +507,11 @@ static void release_table( MSIDATABASE *db, MSITABLE *table ) ...@@ -523,10 +507,11 @@ static void release_table( MSIDATABASE *db, MSITABLE *table )
void free_cached_tables( MSIDATABASE *db ) void free_cached_tables( MSIDATABASE *db )
{ {
while( db->first_table ) while( !list_empty( &db->tables ) )
{ {
MSITABLE *t = db->first_table; MSITABLE *t = LIST_ENTRY( list_head( &db->tables ), MSITABLE, entry );
list_remove( &t->entry );
if ( --t->ref_count ) if ( --t->ref_count )
ERR("table ref count not zero for %s\n", debugstr_w(t->name)); ERR("table ref count not zero for %s\n", debugstr_w(t->name));
remove_table( db, t ); remove_table( db, t );
...@@ -539,7 +524,7 @@ UINT find_cached_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **ptable) ...@@ -539,7 +524,7 @@ UINT find_cached_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **ptable)
{ {
MSITABLE *t; MSITABLE *t;
for( t = db->first_table; t; t=t->next ) LIST_FOR_EACH_ENTRY( t, &db->tables, MSITABLE, entry )
{ {
if( !lstrcmpW( name, t->name ) ) if( !lstrcmpW( name, t->name ) )
{ {
...@@ -1580,7 +1565,7 @@ UINT MSI_CommitTables( MSIDATABASE *db ) ...@@ -1580,7 +1565,7 @@ UINT MSI_CommitTables( MSIDATABASE *db )
return r; return r;
} }
for( table = db->first_table; table; table = table->next ) LIST_FOR_EACH_ENTRY( table, &db->tables, MSITABLE, entry )
{ {
r = save_table( db, table ); r = save_table( db, table );
if( r != ERROR_SUCCESS ) if( r != ERROR_SUCCESS )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment