Skip to content

Commit 8e75cb8

Browse files
winesynclearn-more
authored andcommitted
[WINESYNC] msi: Introduce msi_record_stream_name helper.
Signed-off-by: Piotr Caban <[email protected]> Signed-off-by: Hans Leidekker <[email protected]> Signed-off-by: Alexandre Julliard <[email protected]> wine commit id 5fc68884adec547a5343e8713e8727282b5aa25a by Piotr Caban <[email protected]>
1 parent ce486a0 commit 8e75cb8

File tree

1 file changed

+47
-46
lines changed

1 file changed

+47
-46
lines changed

dll/win32/msi/table.c

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,6 +2188,38 @@ UINT TABLE_CreateView( MSIDATABASE *db, LPCWSTR name, MSIVIEW **view )
21882188
return ERROR_SUCCESS;
21892189
}
21902190

2191+
static UINT msi_record_stream_name( const MSITABLEVIEW *tv, MSIRECORD *rec, LPWSTR name, UINT *len )
2192+
{
2193+
UINT p = 0, l, i, r;
2194+
2195+
l = wcslen( tv->name );
2196+
if (name && *len > l)
2197+
memcpy(name, tv->name, l * sizeof(WCHAR));
2198+
p += l;
2199+
2200+
for ( i = 0; i < tv->num_cols; i++ )
2201+
{
2202+
if (!(tv->columns[i].type & MSITYPE_KEY))
2203+
continue;
2204+
2205+
if (name && *len > p + 1)
2206+
name[p] = '.';
2207+
p++;
2208+
2209+
l = (*len > p ? *len - p : 0);
2210+
r = MSI_RecordGetStringW( rec, i + 1, name ? name + p : NULL, &l );
2211+
if (r != ERROR_SUCCESS)
2212+
return r;
2213+
p += l;
2214+
}
2215+
2216+
if (name && *len > p)
2217+
name[p] = 0;
2218+
2219+
*len = p;
2220+
return ERROR_SUCCESS;
2221+
}
2222+
21912223
UINT MSI_CommitTables( MSIDATABASE *db )
21922224
{
21932225
UINT r, bytes_per_strref;
@@ -2252,61 +2284,30 @@ static UINT read_raw_int(const BYTE *data, UINT col, UINT bytes)
22522284

22532285
static UINT msi_record_encoded_stream_name( const MSITABLEVIEW *tv, MSIRECORD *rec, LPWSTR *pstname )
22542286
{
2255-
LPWSTR stname = NULL, sval, p;
2256-
DWORD len;
2257-
UINT i, r;
2287+
UINT r, len;
2288+
WCHAR *name;
22582289

22592290
TRACE("%p %p\n", tv, rec);
22602291

2261-
len = lstrlenW( tv->name ) + 1;
2262-
stname = msi_alloc( len*sizeof(WCHAR) );
2263-
if ( !stname )
2264-
{
2265-
r = ERROR_OUTOFMEMORY;
2266-
goto err;
2267-
}
2292+
r = msi_record_stream_name( tv, rec, NULL, &len );
2293+
if (r != ERROR_SUCCESS)
2294+
return r;
2295+
len++;
22682296

2269-
lstrcpyW( stname, tv->name );
2297+
name = msi_alloc( len * sizeof(WCHAR) );
2298+
if (!name)
2299+
return ERROR_OUTOFMEMORY;
22702300

2271-
for ( i = 0; i < tv->num_cols; i++ )
2301+
r = msi_record_stream_name( tv, rec, name, &len );
2302+
if (r != ERROR_SUCCESS)
22722303
{
2273-
if ( tv->columns[i].type & MSITYPE_KEY )
2274-
{
2275-
sval = msi_dup_record_field( rec, i + 1 );
2276-
if ( !sval )
2277-
{
2278-
r = ERROR_OUTOFMEMORY;
2279-
goto err;
2280-
}
2281-
2282-
len += lstrlenW( szDot ) + lstrlenW ( sval );
2283-
p = msi_realloc ( stname, len*sizeof(WCHAR) );
2284-
if ( !p )
2285-
{
2286-
r = ERROR_OUTOFMEMORY;
2287-
msi_free(sval);
2288-
goto err;
2289-
}
2290-
stname = p;
2291-
2292-
lstrcatW( stname, szDot );
2293-
lstrcatW( stname, sval );
2294-
2295-
msi_free( sval );
2296-
}
2297-
else
2298-
continue;
2304+
msi_free( name );
2305+
return r;
22992306
}
23002307

2301-
*pstname = encode_streamname( FALSE, stname );
2302-
msi_free( stname );
2303-
2308+
*pstname = encode_streamname( FALSE, name );
2309+
msi_free( name );
23042310
return ERROR_SUCCESS;
2305-
2306-
err:
2307-
msi_free ( stname );
2308-
*pstname = NULL;
2309-
return r;
23102311
}
23112312

23122313
static MSIRECORD *msi_get_transform_record( const MSITABLEVIEW *tv, const string_table *st,

0 commit comments

Comments
 (0)