[2/4] msi: Make the column and table name parameters of get_column_info const.
Hans Leidekker
hans at codeweavers.com
Wed Jul 27 03:53:10 CDT 2011
---
dlls/msi/alter.c | 5 ++---
dlls/msi/create.c | 5 ++---
dlls/msi/delete.c | 5 ++---
dlls/msi/distinct.c | 5 ++---
dlls/msi/insert.c | 28 ++++++----------------------
dlls/msi/join.c | 6 ++----
dlls/msi/msipriv.h | 7 ++++---
dlls/msi/msiquery.c | 14 +++-----------
dlls/msi/select.c | 9 +++------
dlls/msi/storages.c | 39 +++++++--------------------------------
dlls/msi/streams.c | 37 ++++++-------------------------------
dlls/msi/table.c | 9 ++++-----
dlls/msi/update.c | 5 ++---
dlls/msi/where.c | 5 ++---
14 files changed, 47 insertions(+), 132 deletions(-)
diff --git a/dlls/msi/alter.c b/dlls/msi/alter.c
index 93d322b..9daab59 100644
--- a/dlls/msi/alter.c
+++ b/dlls/msi/alter.c
@@ -185,9 +185,8 @@ static UINT ALTER_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *col
return ERROR_FUNCTION_FAILED;
}
-static UINT ALTER_get_column_info( struct tagMSIVIEW *view,
- UINT n, LPWSTR *name, UINT *type, BOOL *temporary,
- LPWSTR *table_name)
+static UINT ALTER_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
+ UINT *type, BOOL *temporary, LPCWSTR *table_name )
{
MSIALTERVIEW *av = (MSIALTERVIEW*)view;
diff --git a/dlls/msi/create.c b/dlls/msi/create.c
index c55390c..592d73b 100644
--- a/dlls/msi/create.c
+++ b/dlls/msi/create.c
@@ -91,9 +91,8 @@ static UINT CREATE_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *co
return ERROR_FUNCTION_FAILED;
}
-static UINT CREATE_get_column_info( struct tagMSIVIEW *view,
- UINT n, LPWSTR *name, UINT *type, BOOL *temporary,
- LPWSTR *table_name)
+static UINT CREATE_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
+ UINT *type, BOOL *temporary, LPCWSTR *table_name )
{
MSICREATEVIEW *cv = (MSICREATEVIEW*)view;
diff --git a/dlls/msi/delete.c b/dlls/msi/delete.c
index 210fc9e..4472409 100644
--- a/dlls/msi/delete.c
+++ b/dlls/msi/delete.c
@@ -126,9 +126,8 @@ static UINT DELETE_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *co
return dv->table->ops->get_dimensions( dv->table, NULL, cols );
}
-static UINT DELETE_get_column_info( struct tagMSIVIEW *view,
- UINT n, LPWSTR *name, UINT *type, BOOL *temporary,
- LPWSTR *table_name)
+static UINT DELETE_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
+ UINT *type, BOOL *temporary, LPCWSTR *table_name )
{
MSIDELETEVIEW *dv = (MSIDELETEVIEW*)view;
diff --git a/dlls/msi/distinct.c b/dlls/msi/distinct.c
index 06beece..3737d28 100644
--- a/dlls/msi/distinct.c
+++ b/dlls/msi/distinct.c
@@ -204,9 +204,8 @@ static UINT DISTINCT_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *
return dv->table->ops->get_dimensions( dv->table, NULL, cols );
}
-static UINT DISTINCT_get_column_info( struct tagMSIVIEW *view,
- UINT n, LPWSTR *name, UINT *type, BOOL *temporary,
- LPWSTR *table_name)
+static UINT DISTINCT_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
+ UINT *type, BOOL *temporary, LPCWSTR *table_name )
{
MSIDISTINCTVIEW *dv = (MSIDISTINCTVIEW*)view;
diff --git a/dlls/msi/insert.c b/dlls/msi/insert.c
index 03e1bd9..c404929 100644
--- a/dlls/msi/insert.c
+++ b/dlls/msi/insert.c
@@ -109,23 +109,16 @@ err:
*/
static BOOL msi_columns_in_order(MSIINSERTVIEW *iv, UINT col_count)
{
- LPWSTR a, b = NULL;
+ LPCWSTR a, b;
UINT i;
- int res;
for (i = 1; i <= col_count; i++)
{
iv->sv->ops->get_column_info(iv->sv, i, &a, NULL, NULL, NULL);
iv->table->ops->get_column_info(iv->table, i, &b, NULL, NULL, NULL);
- res = strcmpW( a, b );
- msi_free(a);
- msi_free(b);
-
- if (res != 0)
- return FALSE;
+ if (strcmpW( a, b )) return FALSE;
}
-
return TRUE;
}
@@ -137,8 +130,7 @@ static UINT msi_arrange_record(MSIINSERTVIEW *iv, MSIRECORD **values)
MSIRECORD *padded;
UINT col_count, val_count;
UINT r, i, colidx;
- LPWSTR a, b = NULL;
- int res;
+ LPCWSTR a, b;
r = iv->table->ops->get_dimensions(iv->table, NULL, &col_count);
if (r != ERROR_SUCCESS)
@@ -169,22 +161,15 @@ static UINT msi_arrange_record(MSIINSERTVIEW *iv, MSIRECORD **values)
if (r != ERROR_SUCCESS)
goto err;
- res = strcmpW( a, b );
- msi_free(b);
-
- if (res == 0)
+ if (!strcmpW( a, b ))
{
MSI_RecordCopyField(*values, colidx, padded, i);
break;
}
}
-
- msi_free(a);
}
-
msiobj_release(&(*values)->hdr);
*values = padded;
-
return ERROR_SUCCESS;
err:
@@ -293,9 +278,8 @@ static UINT INSERT_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *co
return sv->ops->get_dimensions( sv, rows, cols );
}
-static UINT INSERT_get_column_info( struct tagMSIVIEW *view,
- UINT n, LPWSTR *name, UINT *type, BOOL *temporary,
- LPWSTR *table_name)
+static UINT INSERT_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
+ UINT *type, BOOL *temporary, LPCWSTR *table_name )
{
MSIINSERTVIEW *iv = (MSIINSERTVIEW*)view;
MSIVIEW *sv;
diff --git a/dlls/msi/join.c b/dlls/msi/join.c
index 7fe7f1c..b2d53dd 100644
--- a/dlls/msi/join.c
+++ b/dlls/msi/join.c
@@ -194,9 +194,8 @@ static UINT JOIN_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *cols
return ERROR_SUCCESS;
}
-static UINT JOIN_get_column_info( struct tagMSIVIEW *view,
- UINT n, LPWSTR *name, UINT *type, BOOL *temporary,
- LPWSTR *table_name )
+static UINT JOIN_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
+ UINT *type, BOOL *temporary, LPCWSTR *table_name )
{
MSIJOINVIEW *jv = (MSIJOINVIEW*)view;
JOINTABLE *table;
@@ -213,7 +212,6 @@ static UINT JOIN_get_column_info( struct tagMSIVIEW *view,
return table->view->ops->get_column_info(table->view, n - cols,
name, type, temporary,
table_name);
-
cols += table->columns;
}
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index 4f1ce53..bd95660 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -261,11 +261,10 @@ typedef struct tagMSIVIEWOPS
/*
* get_column_info - returns the name and type of a specific column
*
- * The name and tablename is HeapAlloc'ed by this function and should be
- * freed by the caller.
* The column information can be queried at any time.
*/
- UINT (*get_column_info)( struct tagMSIVIEW *view, UINT n, LPWSTR *name, UINT *type, BOOL *temporary, LPWSTR *tableName);
+ UINT (*get_column_info)( struct tagMSIVIEW *view, UINT n, LPCWSTR *name, UINT *type,
+ BOOL *temporary, LPCWSTR *table_name );
/*
* modify - not yet implemented properly
@@ -1158,6 +1157,8 @@ static const WCHAR szInstallLevel[] = {'I','N','S','T','A','L','L','L','E','V','
static const WCHAR szCostInitialize[] = {'C','o','s','t','I','n','i','t','i','a','l','i','z','e',0};
static const WCHAR szAppDataFolder[] = {'A','p','p','D','a','t','a','F','o','l','d','e','r',0};
static const WCHAR szRollbackDisabled[] = {'R','o','l','l','b','a','c','k','D','i','s','a','b','l','e','d',0};
+static const WCHAR szName[] = {'N','a','m','e',0};
+static const WCHAR szData[] = {'D','a','t','a',0};
/* memory allocation macro functions */
static void *msi_alloc( size_t len ) __WINE_ALLOC_SIZE(1);
diff --git a/dlls/msi/msiquery.c b/dlls/msi/msiquery.c
index 9154c98..08a87a9 100644
--- a/dlls/msi/msiquery.c
+++ b/dlls/msi/msiquery.c
@@ -58,8 +58,7 @@ static void MSI_CloseView( MSIOBJECTHDR *arg )
UINT VIEW_find_column( MSIVIEW *table, LPCWSTR name, LPCWSTR table_name, UINT *n )
{
- LPWSTR col_name;
- LPWSTR haystack_table_name;
+ LPCWSTR col_name, haystack_table_name;
UINT i, count, r;
r = table->ops->get_dimensions( table, NULL, &count );
@@ -70,7 +69,6 @@ UINT VIEW_find_column( MSIVIEW *table, LPCWSTR name, LPCWSTR table_name, UINT *n
{
INT x;
- col_name = NULL;
r = table->ops->get_column_info( table, i, &col_name, NULL,
NULL, &haystack_table_name );
if( r != ERROR_SUCCESS )
@@ -78,15 +76,12 @@ UINT VIEW_find_column( MSIVIEW *table, LPCWSTR name, LPCWSTR table_name, UINT *n
x = strcmpW( name, col_name );
if( table_name )
x |= strcmpW( table_name, haystack_table_name );
- msi_free( col_name );
- msi_free( haystack_table_name );
if( !x )
{
*n = i;
return ERROR_SUCCESS;
}
}
-
return ERROR_INVALID_PARAMETER;
}
@@ -536,7 +531,7 @@ UINT MSI_ViewGetColumnInfo( MSIQUERY *query, MSICOLINFO info, MSIRECORD **prec )
UINT r = ERROR_FUNCTION_FAILED, i, count = 0, type;
MSIRECORD *rec;
MSIVIEW *view = query->view;
- LPWSTR name;
+ LPCWSTR name;
BOOL temporary;
if( !view )
@@ -558,17 +553,14 @@ UINT MSI_ViewGetColumnInfo( MSIQUERY *query, MSICOLINFO info, MSIRECORD **prec )
for( i=0; i<count; i++ )
{
name = NULL;
- r = view->ops->get_column_info( view, i+1, &name, &type, &temporary,
- NULL );
+ r = view->ops->get_column_info( view, i+1, &name, &type, &temporary, NULL );
if( r != ERROR_SUCCESS )
continue;
if (info == MSICOLINFO_NAMES)
MSI_RecordSetStringW( rec, i+1, name );
else
msi_set_record_type_string( rec, i+1, type, temporary );
- msi_free( name );
}
-
*prec = rec;
return ERROR_SUCCESS;
}
diff --git a/dlls/msi/select.c b/dlls/msi/select.c
index f6b5dae..696c3b9 100644
--- a/dlls/msi/select.c
+++ b/dlls/msi/select.c
@@ -208,9 +208,8 @@ static UINT SELECT_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *co
return sv->table->ops->get_dimensions( sv->table, rows, NULL );
}
-static UINT SELECT_get_column_info( struct tagMSIVIEW *view,
- UINT n, LPWSTR *name, UINT *type, BOOL *temporary,
- LPWSTR *table_name)
+static UINT SELECT_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
+ UINT *type, BOOL *temporary, LPCWSTR *table_name )
{
MSISELECTVIEW *sv = (MSISELECTVIEW*)view;
@@ -232,7 +231,6 @@ static UINT msi_select_update(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row)
{
MSISELECTVIEW *sv = (MSISELECTVIEW*)view;
UINT r, i, num_columns, col, type, val;
- LPWSTR name;
LPCWSTR str;
MSIRECORD *mod;
@@ -248,8 +246,7 @@ static UINT msi_select_update(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row)
{
col = sv->cols[i];
- r = SELECT_get_column_info(view, i + 1, &name, &type, NULL, NULL);
- msi_free(name);
+ r = SELECT_get_column_info(view, i + 1, NULL, &type, NULL, NULL);
if (r != ERROR_SUCCESS)
{
ERR("Failed to get column information: %d\n", r);
diff --git a/dlls/msi/storages.c b/dlls/msi/storages.c
index 22c9188..c980df8 100644
--- a/dlls/msi/storages.c
+++ b/dlls/msi/storages.c
@@ -280,16 +280,9 @@ static UINT STORAGES_get_dimensions(struct tagMSIVIEW *view, UINT *rows, UINT *c
return ERROR_SUCCESS;
}
-static UINT STORAGES_get_column_info(struct tagMSIVIEW *view, UINT n,
- LPWSTR *name, UINT *type, BOOL *temporary,
- LPWSTR *table_name)
+static UINT STORAGES_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
+ UINT *type, BOOL *temporary, LPCWSTR *table_name )
{
- LPCWSTR name_ptr = NULL;
-
- static const WCHAR Name[] = {'N','a','m','e',0};
- static const WCHAR Data[] = {'D','a','t','a',0};
- static const WCHAR _Storages[] = {'_','S','t','o','r','a','g','e','s',0};
-
TRACE("(%p, %d, %p, %p, %p, %p)\n", view, n, name, type, temporary,
table_name);
@@ -299,35 +292,17 @@ static UINT STORAGES_get_column_info(struct tagMSIVIEW *view, UINT n,
switch (n)
{
case 1:
- name_ptr = Name;
- if (type) *type = MSITYPE_STRING | MAX_STORAGES_NAME_LEN;
+ if (name) *name = szName;
+ if (type) *type = MSITYPE_STRING | MSITYPE_VALID | MAX_STORAGES_NAME_LEN;
break;
case 2:
- name_ptr = Data;
+ if (name) *name = szData;
if (type) *type = MSITYPE_STRING | MSITYPE_VALID | MSITYPE_NULLABLE;
break;
}
-
- if (name)
- {
- *name = strdupW(name_ptr);
- if (!*name) return ERROR_FUNCTION_FAILED;
- }
-
- if (table_name)
- {
- *table_name = strdupW(_Storages);
- if (!*table_name)
- {
- msi_free(name);
- return ERROR_FUNCTION_FAILED;
- }
- }
-
- if (temporary)
- *temporary = FALSE;
-
+ if (table_name) *table_name = szStorages;
+ if (temporary) *temporary = FALSE;
return ERROR_SUCCESS;
}
diff --git a/dlls/msi/streams.c b/dlls/msi/streams.c
index 579dad1..56b38e3 100644
--- a/dlls/msi/streams.c
+++ b/dlls/msi/streams.c
@@ -267,16 +267,9 @@ static UINT STREAMS_get_dimensions(struct tagMSIVIEW *view, UINT *rows, UINT *co
return ERROR_SUCCESS;
}
-static UINT STREAMS_get_column_info(struct tagMSIVIEW *view, UINT n,
- LPWSTR *name, UINT *type, BOOL *temporary,
- LPWSTR *table_name)
+static UINT STREAMS_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
+ UINT *type, BOOL *temporary, LPCWSTR *table_name )
{
- LPCWSTR name_ptr = NULL;
-
- static const WCHAR Name[] = {'N','a','m','e',0};
- static const WCHAR Data[] = {'D','a','t','a',0};
- static const WCHAR _Streams[] = {'_','S','t','r','e','a','m','s',0};
-
TRACE("(%p, %d, %p, %p, %p, %p)\n", view, n, name, type, temporary,
table_name);
@@ -286,35 +279,17 @@ static UINT STREAMS_get_column_info(struct tagMSIVIEW *view, UINT n,
switch (n)
{
case 1:
- name_ptr = Name;
+ if (name) *name = szName;
if (type) *type = MSITYPE_STRING | MSITYPE_VALID | MAX_STREAM_NAME_LEN;
break;
case 2:
- name_ptr = Data;
+ if (name) *name = szData;
if (type) *type = MSITYPE_STRING | MSITYPE_VALID | MSITYPE_NULLABLE;
break;
}
-
- if (name)
- {
- *name = strdupW(name_ptr);
- if (!*name) return ERROR_FUNCTION_FAILED;
- }
-
- if (table_name)
- {
- *table_name = strdupW(_Streams);
- if (!*table_name)
- {
- msi_free(name);
- return ERROR_FUNCTION_FAILED;
- }
- }
-
- if (temporary)
- *temporary = FALSE;
-
+ if (table_name) *table_name = szStreams;
+ if (temporary) *temporary = FALSE;
return ERROR_SUCCESS;
}
diff --git a/dlls/msi/table.c b/dlls/msi/table.c
index 5bc1e3d..99a72c6 100644
--- a/dlls/msi/table.c
+++ b/dlls/msi/table.c
@@ -85,7 +85,6 @@ struct tagMSITABLE
/* information for default tables */
static const WCHAR szTables[] = {'_','T','a','b','l','e','s',0};
static const WCHAR szTable[] = {'T','a','b','l','e',0};
-static const WCHAR szName[] = {'N','a','m','e',0};
static const WCHAR szColumns[] = {'_','C','o','l','u','m','n','s',0};
static const WCHAR szNumber[] = {'N','u','m','b','e','r',0};
static const WCHAR szType[] = {'T','y','p','e',0};
@@ -1502,8 +1501,8 @@ static UINT TABLE_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *col
}
static UINT TABLE_get_column_info( struct tagMSIVIEW *view,
- UINT n, LPWSTR *name, UINT *type, BOOL *temporary,
- LPWSTR *table_name )
+ UINT n, LPCWSTR *name, UINT *type, BOOL *temporary,
+ LPCWSTR *table_name )
{
MSITABLEVIEW *tv = (MSITABLEVIEW*)view;
@@ -1514,14 +1513,14 @@ static UINT TABLE_get_column_info( struct tagMSIVIEW *view,
if( name )
{
- *name = strdupW( tv->columns[n-1].colname );
+ *name = tv->columns[n-1].colname;
if( !*name )
return ERROR_FUNCTION_FAILED;
}
if( table_name )
{
- *table_name = strdupW( tv->columns[n-1].tablename );
+ *table_name = tv->columns[n-1].tablename;
if( !*table_name )
return ERROR_FUNCTION_FAILED;
}
diff --git a/dlls/msi/update.c b/dlls/msi/update.c
index c80d5a9..a92aac0 100644
--- a/dlls/msi/update.c
+++ b/dlls/msi/update.c
@@ -154,9 +154,8 @@ static UINT UPDATE_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *co
return wv->ops->get_dimensions( wv, rows, cols );
}
-static UINT UPDATE_get_column_info( struct tagMSIVIEW *view,
- UINT n, LPWSTR *name, UINT *type, BOOL *temporary,
- LPWSTR* table_name )
+static UINT UPDATE_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
+ UINT *type, BOOL *temporary, LPCWSTR *table_name )
{
MSIUPDATEVIEW *uv = (MSIUPDATEVIEW*)view;
MSIVIEW *wv;
diff --git a/dlls/msi/where.c b/dlls/msi/where.c
index 35a6074..ae31e81 100644
--- a/dlls/msi/where.c
+++ b/dlls/msi/where.c
@@ -496,9 +496,8 @@ static UINT WHERE_get_dimensions( struct tagMSIVIEW *view, UINT *rows, UINT *col
return wv->table->ops->get_dimensions( wv->table, NULL, cols );
}
-static UINT WHERE_get_column_info( struct tagMSIVIEW *view,
- UINT n, LPWSTR *name, UINT *type, BOOL *temporary,
- LPWSTR *table_name)
+static UINT WHERE_get_column_info( struct tagMSIVIEW *view, UINT n, LPCWSTR *name,
+ UINT *type, BOOL *temporary, LPCWSTR *table_name )
{
MSIWHEREVIEW *wv = (MSIWHEREVIEW*)view;
--
1.7.4.1
More information about the wine-patches
mailing list