From 5f1b258c9c4d43ba584c83769b57b441a8a7e165 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Wed, 14 Sep 2005 10:07:26 +0000 Subject: [PATCH] Convert the list of tables to a standard list. --- dlls/msi/database.c | 6 +++--- dlls/msi/msipriv.h | 2 +- dlls/msi/table.c | 31 ++++++++----------------------- 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/dlls/msi/database.c b/dlls/msi/database.c index 44aab3a5841..136fa5661e2 100644 --- a/dlls/msi/database.c +++ b/dlls/msi/database.c @@ -134,15 +134,14 @@ UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb) goto end; } - if(( memcmp( &stat.clsid, &CLSID_MsiDatabase, sizeof (GUID) ) ) - && ( memcmp( &stat.clsid, &CLSID_MsiPatch, sizeof (GUID) ) )) + if ( !IsEqualGUID( &stat.clsid, &CLSID_MsiDatabase ) && + !IsEqualGUID( &stat.clsid, &CLSID_MsiPatch ) ) { ERR("storage GUID is not a MSI database GUID %s\n", debugstr_guid(&stat.clsid) ); goto end; } - db = alloc_msiobject( MSIHANDLETYPE_DATABASE, sizeof (MSIDATABASE), MSI_CloseDatabase ); if( !db ) @@ -156,6 +155,7 @@ UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb) db->storage = stg; db->mode = szMode; + list_init( &db->tables ); ret = load_string_table( db ); if( ret != ERROR_SUCCESS ) diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index e99201631bf..6e4dc852c0d 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -67,7 +67,7 @@ typedef struct tagMSIDATABASE IStorage *storage; string_table *strings; LPCWSTR mode; - MSITABLE *first_table, *last_table; + struct list tables; } MSIDATABASE; typedef struct tagMSIVIEW MSIVIEW; diff --git a/dlls/msi/table.c b/dlls/msi/table.c index 89c2611fe51..42330e371fe 100644 --- a/dlls/msi/table.c +++ b/dlls/msi/table.c @@ -53,8 +53,7 @@ struct tagMSITABLE USHORT **data; UINT ref_count; UINT row_count; - struct tagMSITABLE *next; - struct tagMSITABLE *prev; + struct list entry; WCHAR name[1]; }; @@ -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 */ void add_table(MSIDATABASE *db, MSITABLE *table) { - table->next = db->first_table; - table->prev = NULL; - if( db->first_table ) - db->first_table->prev = table; - else - db->last_table = table; - db->first_table = table; + list_add_head( &db->tables, &table->entry ); } /* remove from the list of cached tables */ void remove_table( MSIDATABASE *db, MSITABLE *table ) { - if( table->next ) - 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; + list_remove( &table->entry ); } 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 ) { - 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 ) ERR("table ref count not zero for %s\n", debugstr_w(t->name)); remove_table( db, t ); @@ -539,7 +524,7 @@ UINT find_cached_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **ptable) { 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 ) ) { @@ -1580,7 +1565,7 @@ UINT MSI_CommitTables( MSIDATABASE *db ) 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 ); if( r != ERROR_SUCCESS )