From 6b5f290d750b79fa3f95dfe182689e7cf28c157c Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Fri, 16 Sep 2005 19:01:40 +0000 Subject: [PATCH] Make load_string_table return the string table. --- dlls/msi/database.c | 6 ++++-- dlls/msi/msipriv.h | 2 +- dlls/msi/table.c | 25 +++++++++---------------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/dlls/msi/database.c b/dlls/msi/database.c index 136fa5661e..971a59add5 100644 --- a/dlls/msi/database.c +++ b/dlls/msi/database.c @@ -157,10 +157,12 @@ UINT MSI_OpenDatabaseW(LPCWSTR szDBPath, LPCWSTR szPersist, MSIDATABASE **pdb) db->mode = szMode; list_init( &db->tables ); - ret = load_string_table( db ); - if( ret != ERROR_SUCCESS ) + db->strings = load_string_table( stg ); + if( !db->strings ) goto end; + ret = ERROR_SUCCESS; + msiobj_addref( &db->hdr ); IStorage_AddRef( stg ); *pdb = db; diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index 62b301d21b..10921e9231 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -276,7 +276,7 @@ extern void free_table( MSIDATABASE *db, MSITABLE *table ); extern void free_cached_tables( MSIDATABASE *db ); extern UINT find_cached_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **table); extern UINT get_table(MSIDATABASE *db, LPCWSTR name, MSITABLE **table); -extern UINT load_string_table( MSIDATABASE *db ); +extern string_table *load_string_table( IStorage *stg ); extern UINT MSI_CommitTables( MSIDATABASE *db ); extern HRESULT init_string_table( IStorage *stg ); diff --git a/dlls/msi/table.c b/dlls/msi/table.c index 42330e371f..6915505545 100644 --- a/dlls/msi/table.c +++ b/dlls/msi/table.c @@ -684,27 +684,22 @@ HRESULT init_string_table( IStorage *stg ) return r; } -UINT load_string_table( MSIDATABASE *db ) +string_table *load_string_table( IStorage *stg ) { + string_table *st = NULL; CHAR *data; USHORT *pool; - UINT r, ret = ERROR_FUNCTION_FAILED, datasize = 0, poolsize = 0, codepage; + UINT r, datasize = 0, poolsize = 0, codepage; DWORD i, count, offset, len, n; static const WCHAR szStringData[] = { '_','S','t','r','i','n','g','D','a','t','a',0 }; static const WCHAR szStringPool[] = { '_','S','t','r','i','n','g','P','o','o','l',0 }; - if( db->strings ) - { - msi_destroy_stringtable( db->strings ); - db->strings = NULL; - } - - r = read_stream_data( db->storage, szStringPool, &pool, &poolsize ); + r = read_stream_data( stg, szStringPool, &pool, &poolsize ); if( r != ERROR_SUCCESS) goto end; - r = read_stream_data( db->storage, szStringData, (USHORT**)&data, &datasize ); + r = read_stream_data( stg, szStringData, (USHORT**)&data, &datasize ); if( r != ERROR_SUCCESS) goto end; @@ -713,7 +708,7 @@ UINT load_string_table( MSIDATABASE *db ) codepage = pool[0] | ( pool[1] << 16 ); else codepage = CP_ACP; - db->strings = msi_init_stringtable( count, codepage ); + st = msi_init_stringtable( count, codepage ); offset = 0; n = 1; @@ -738,7 +733,7 @@ UINT load_string_table( MSIDATABASE *db ) /* don't add the high word of a string's length as a string */ if ( len || !pool[i*2+1] ) { - r = msi_addstring( db->strings, n, data+offset, len, pool[i*2+1] ); + r = msi_addstring( st, n, data+offset, len, pool[i*2+1] ); if( r != n ) ERR("Failed to add string %ld\n", n ); n++; @@ -752,13 +747,11 @@ UINT load_string_table( MSIDATABASE *db ) TRACE("Loaded %ld strings\n", count); - ret = ERROR_SUCCESS; - end: HeapFree( GetProcessHeap(), 0, pool ); HeapFree( GetProcessHeap(), 0, data ); - return ret; + return st; } static UINT save_string_table( MSIDATABASE *db ) @@ -806,7 +799,7 @@ static UINT save_string_table( MSIDATABASE *db ) } if( sz && (sz < (datasize - used ) ) ) sz--; - TRACE("adding %u bytes %s\n", sz, data+used ); + TRACE("adding %u bytes %s\n", sz, debugstr_a(data+used) ); pool[ i*2 ] = sz; pool[ i*2 + 1 ] = msi_id_refcount( db->strings, i ); used += sz;