diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index 2b7d6baa677..fada8c67745 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -660,8 +660,7 @@ enum StringPersistence StringNonPersistent = 1 }; -extern BOOL msi_addstringW( string_table *st, UINT string_no, const WCHAR *data, int len, USHORT refcount, enum StringPersistence persistence ); - +extern BOOL msi_addstringW( string_table *st, const WCHAR *data, int len, USHORT refcount, enum StringPersistence persistence ); extern UINT msi_string2idW( const string_table *st, LPCWSTR buffer, UINT *id ); extern VOID msi_destroy_stringtable( string_table *st ); extern const WCHAR *msi_string_lookup_id( const string_table *st, UINT id ); diff --git a/dlls/msi/storages.c b/dlls/msi/storages.c index 5b555badcfa..3e8887437a7 100644 --- a/dlls/msi/storages.c +++ b/dlls/msi/storages.c @@ -77,7 +77,7 @@ static STORAGE *create_storage(MSISTORAGESVIEW *sv, LPCWSTR name, IStorage *stg) if (!storage) return NULL; - storage->str_index = msi_addstringW(sv->db->strings, 0, name, -1, 1, StringNonPersistent); + storage->str_index = msi_addstringW(sv->db->strings, name, -1, 1, StringNonPersistent); storage->storage = stg; if (storage->storage) diff --git a/dlls/msi/streams.c b/dlls/msi/streams.c index e4204a2addb..59e845df82d 100644 --- a/dlls/msi/streams.c +++ b/dlls/msi/streams.c @@ -84,7 +84,7 @@ static STREAM *create_stream(MSISTREAMSVIEW *sv, LPCWSTR name, BOOL encoded, ISt name = decoded; } - stream->str_index = msi_addstringW(sv->db->strings, 0, name, -1, 1, StringNonPersistent); + stream->str_index = msi_addstringW(sv->db->strings, name, -1, 1, StringNonPersistent); stream->stream = stm; return stream; } diff --git a/dlls/msi/string.c b/dlls/msi/string.c index 84f4e71fca6..21b1db2a405 100644 --- a/dlls/msi/string.c +++ b/dlls/msi/string.c @@ -288,42 +288,28 @@ static int msi_addstring( string_table *st, UINT n, const CHAR *data, int len, U return n; } -int msi_addstringW( string_table *st, UINT n, const WCHAR *data, int len, USHORT refcount, enum StringPersistence persistence ) +int msi_addstringW( string_table *st, const WCHAR *data, int len, USHORT refcount, enum StringPersistence persistence ) { + UINT n; LPWSTR str; - /* TRACE("[%2d] = %s\n", string_no, debugstr_an(data,len) ); */ - if( !data ) return 0; if( !data[0] ) return 0; - if( n > 0 ) + + if( msi_string2idW( st, data, &n ) == ERROR_SUCCESS ) { - if( st->strings[n].persistent_refcount || - st->strings[n].nonpersistent_refcount ) - return -1; - } - else - { - if( ERROR_SUCCESS == msi_string2idW( st, data, &n ) ) - { - if (persistence == StringPersistent) - st->strings[n].persistent_refcount += refcount; - else - st->strings[n].nonpersistent_refcount += refcount; - return n; - } - n = st_find_free_entry( st ); - if( n == -1 ) - return -1; + if (persistence == StringPersistent) + st->strings[n].persistent_refcount += refcount; + else + st->strings[n].nonpersistent_refcount += refcount; + return n; } - if( n < 1 ) - { - ERR("invalid index adding %s (%d)\n", debugstr_w( data ), n ); + n = st_find_free_entry( st ); + if( n == -1 ) return -1; - } /* allocate a new string */ if(len<0) diff --git a/dlls/msi/table.c b/dlls/msi/table.c index 6737ac59168..3b117ae53c4 100644 --- a/dlls/msi/table.c +++ b/dlls/msi/table.c @@ -1383,7 +1383,7 @@ static UINT TABLE_set_row( struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UI if ( r != ERROR_SUCCESS ) { LPCWSTR sval = MSI_RecordGetString( rec, i + 1 ); - val = msi_addstringW( tv->db->strings, 0, sval, -1, 1, + val = msi_addstringW( tv->db->strings, sval, -1, 1, persistent ? StringPersistent : StringNonPersistent ); }