Commit a7f455b9 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

msi: Use a BOOL to track string persistence.

parent c2810f40
...@@ -742,13 +742,7 @@ extern UINT msi_commit_streams( MSIDATABASE *db ) DECLSPEC_HIDDEN; ...@@ -742,13 +742,7 @@ extern UINT msi_commit_streams( MSIDATABASE *db ) DECLSPEC_HIDDEN;
/* string table functions */ /* string table functions */
enum StringPersistence extern BOOL msi_add_string( string_table *st, const WCHAR *data, int len, BOOL persistent ) DECLSPEC_HIDDEN;
{
StringPersistent = 0,
StringNonPersistent = 1
};
extern BOOL msi_add_string( string_table *st, const WCHAR *data, int len, enum StringPersistence persistence ) DECLSPEC_HIDDEN;
extern UINT msi_string2id( const string_table *st, const WCHAR *data, int len, UINT *id ) DECLSPEC_HIDDEN; extern UINT msi_string2id( const string_table *st, const WCHAR *data, int len, UINT *id ) DECLSPEC_HIDDEN;
extern VOID msi_destroy_stringtable( string_table *st ) DECLSPEC_HIDDEN; extern VOID msi_destroy_stringtable( string_table *st ) DECLSPEC_HIDDEN;
extern const WCHAR *msi_string_lookup( const string_table *st, UINT id, int *len ) DECLSPEC_HIDDEN; extern const WCHAR *msi_string_lookup( const string_table *st, UINT id, int *len ) DECLSPEC_HIDDEN;
......
...@@ -77,7 +77,7 @@ static STORAGE *create_storage(MSISTORAGESVIEW *sv, LPCWSTR name, IStorage *stg) ...@@ -77,7 +77,7 @@ static STORAGE *create_storage(MSISTORAGESVIEW *sv, LPCWSTR name, IStorage *stg)
if (!storage) if (!storage)
return NULL; return NULL;
storage->str_index = msi_add_string(sv->db->strings, name, -1, StringNonPersistent); storage->str_index = msi_add_string(sv->db->strings, name, -1, FALSE);
storage->storage = stg; storage->storage = stg;
if (storage->storage) if (storage->storage)
......
...@@ -127,7 +127,7 @@ static UINT STREAMS_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, U ...@@ -127,7 +127,7 @@ static UINT STREAMS_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, U
const WCHAR *name = MSI_RecordGetString( rec, 1 ); const WCHAR *name = MSI_RecordGetString( rec, 1 );
if (!name) return ERROR_INVALID_PARAMETER; if (!name) return ERROR_INVALID_PARAMETER;
sv->db->streams[row].str_index = msi_add_string( sv->db->strings, name, -1, StringNonPersistent ); sv->db->streams[row].str_index = msi_add_string( sv->db->strings, name, -1, FALSE );
} }
if (mask & 2) if (mask & 2)
{ {
...@@ -399,7 +399,7 @@ static UINT append_stream( MSIDATABASE *db, const WCHAR *name, IStream *stream ) ...@@ -399,7 +399,7 @@ static UINT append_stream( MSIDATABASE *db, const WCHAR *name, IStream *stream )
if (!streams_resize_table( db, db->num_streams + 1 )) if (!streams_resize_table( db, db->num_streams + 1 ))
return ERROR_OUTOFMEMORY; return ERROR_OUTOFMEMORY;
db->streams[i].str_index = msi_add_string( db->strings, name, -1, StringNonPersistent ); db->streams[i].str_index = msi_add_string( db->strings, name, -1, FALSE );
db->streams[i].stream = stream; db->streams[i].stream = stream;
db->num_streams++; db->num_streams++;
......
...@@ -209,9 +209,9 @@ static void insert_string_sorted( string_table *st, UINT string_id ) ...@@ -209,9 +209,9 @@ static void insert_string_sorted( string_table *st, UINT string_id )
} }
static void set_st_entry( string_table *st, UINT n, WCHAR *str, int len, USHORT refcount, static void set_st_entry( string_table *st, UINT n, WCHAR *str, int len, USHORT refcount,
enum StringPersistence persistence ) BOOL persistent )
{ {
if (persistence == StringPersistent) if (persistent)
{ {
st->strings[n].persistent_refcount = refcount; st->strings[n].persistent_refcount = refcount;
st->strings[n].nonpersistent_refcount = 0; st->strings[n].nonpersistent_refcount = 0;
...@@ -257,7 +257,7 @@ static UINT string2id( const string_table *st, const char *buffer, UINT *id ) ...@@ -257,7 +257,7 @@ static UINT string2id( const string_table *st, const char *buffer, UINT *id )
return r; return r;
} }
static int add_string( string_table *st, UINT n, const char *data, UINT len, USHORT refcount, enum StringPersistence persistence ) static int add_string( string_table *st, UINT n, const char *data, UINT len, USHORT refcount, BOOL persistent )
{ {
LPWSTR str; LPWSTR str;
int sz; int sz;
...@@ -274,7 +274,7 @@ static int add_string( string_table *st, UINT n, const char *data, UINT len, USH ...@@ -274,7 +274,7 @@ static int add_string( string_table *st, UINT n, const char *data, UINT len, USH
{ {
if (string2id( st, data, &n ) == ERROR_SUCCESS) if (string2id( st, data, &n ) == ERROR_SUCCESS)
{ {
if (persistence == StringPersistent) if (persistent)
st->strings[n].persistent_refcount += refcount; st->strings[n].persistent_refcount += refcount;
else else
st->strings[n].nonpersistent_refcount += refcount; st->strings[n].nonpersistent_refcount += refcount;
...@@ -299,11 +299,11 @@ static int add_string( string_table *st, UINT n, const char *data, UINT len, USH ...@@ -299,11 +299,11 @@ static int add_string( string_table *st, UINT n, const char *data, UINT len, USH
MultiByteToWideChar( st->codepage, 0, data, len, str, sz ); MultiByteToWideChar( st->codepage, 0, data, len, str, sz );
str[sz] = 0; str[sz] = 0;
set_st_entry( st, n, str, sz, refcount, persistence ); set_st_entry( st, n, str, sz, refcount, persistent );
return n; return n;
} }
int msi_add_string( string_table *st, const WCHAR *data, int len, enum StringPersistence persistence ) int msi_add_string( string_table *st, const WCHAR *data, int len, BOOL persistent )
{ {
UINT n; UINT n;
LPWSTR str; LPWSTR str;
...@@ -318,7 +318,7 @@ int msi_add_string( string_table *st, const WCHAR *data, int len, enum StringPer ...@@ -318,7 +318,7 @@ int msi_add_string( string_table *st, const WCHAR *data, int len, enum StringPer
if (msi_string2id( st, data, len, &n) == ERROR_SUCCESS ) if (msi_string2id( st, data, len, &n) == ERROR_SUCCESS )
{ {
if (persistence == StringPersistent) if (persistent)
st->strings[n].persistent_refcount++; st->strings[n].persistent_refcount++;
else else
st->strings[n].nonpersistent_refcount++; st->strings[n].nonpersistent_refcount++;
...@@ -338,7 +338,7 @@ int msi_add_string( string_table *st, const WCHAR *data, int len, enum StringPer ...@@ -338,7 +338,7 @@ int msi_add_string( string_table *st, const WCHAR *data, int len, enum StringPer
memcpy( str, data, len*sizeof(WCHAR) ); memcpy( str, data, len*sizeof(WCHAR) );
str[len] = 0; str[len] = 0;
set_st_entry( st, n, str, len, 1, persistence ); set_st_entry( st, n, str, len, 1, persistent );
return n; return n;
} }
...@@ -545,7 +545,7 @@ string_table *msi_load_string_table( IStorage *stg, UINT *bytes_per_strref ) ...@@ -545,7 +545,7 @@ string_table *msi_load_string_table( IStorage *stg, UINT *bytes_per_strref )
break; break;
} }
r = add_string( st, n, data+offset, len, refs, StringPersistent ); r = add_string( st, n, data+offset, len, refs, TRUE );
if( r != n ) if( r != n )
ERR("Failed to add string %d\n", n ); ERR("Failed to add string %d\n", n );
n++; n++;
......
...@@ -716,7 +716,6 @@ static UINT get_tablecolumns( MSIDATABASE *db, LPCWSTR szTableName, MSICOLUMNINF ...@@ -716,7 +716,6 @@ static UINT get_tablecolumns( MSIDATABASE *db, LPCWSTR szTableName, MSICOLUMNINF
UINT msi_create_table( MSIDATABASE *db, LPCWSTR name, column_info *col_info, UINT msi_create_table( MSIDATABASE *db, LPCWSTR name, column_info *col_info,
MSICONDITION persistent ) MSICONDITION persistent )
{ {
enum StringPersistence string_persistence = (persistent) ? StringPersistent : StringNonPersistent;
UINT r, nField; UINT r, nField;
MSIVIEW *tv = NULL; MSIVIEW *tv = NULL;
MSIRECORD *rec = NULL; MSIRECORD *rec = NULL;
...@@ -756,8 +755,8 @@ UINT msi_create_table( MSIDATABASE *db, LPCWSTR name, column_info *col_info, ...@@ -756,8 +755,8 @@ UINT msi_create_table( MSIDATABASE *db, LPCWSTR name, column_info *col_info,
for( i = 0, col = col_info; col; i++, col = col->next ) for( i = 0, col = col_info; col; i++, col = col->next )
{ {
UINT table_id = msi_add_string( db->strings, col->table, -1, string_persistence ); UINT table_id = msi_add_string( db->strings, col->table, -1, persistent );
UINT col_id = msi_add_string( db->strings, col->column, -1, string_persistence ); UINT col_id = msi_add_string( db->strings, col->column, -1, persistent );
table->colinfo[ i ].tablename = msi_string_lookup( db->strings, table_id, NULL ); table->colinfo[ i ].tablename = msi_string_lookup( db->strings, table_id, NULL );
table->colinfo[ i ].number = i + 1; table->colinfo[ i ].number = i + 1;
...@@ -1385,8 +1384,7 @@ static UINT TABLE_set_row( struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UI ...@@ -1385,8 +1384,7 @@ static UINT TABLE_set_row( struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UI
{ {
int len; int len;
const WCHAR *sval = msi_record_get_string( rec, i + 1, &len ); const WCHAR *sval = msi_record_get_string( rec, i + 1, &len );
val = msi_add_string( tv->db->strings, sval, len, val = msi_add_string( tv->db->strings, sval, len, persistent );
persistent ? StringPersistent : StringNonPersistent );
} }
else else
{ {
......
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