Commit 9aa23c6c authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi: Store string length in the record structure.

parent 6950ac1d
......@@ -118,6 +118,7 @@ typedef struct tagMSIFIELD
LPWSTR szwVal;
IStream *stream;
} u;
int len;
} MSIFIELD;
typedef struct tagMSIRECORD
......@@ -821,6 +822,7 @@ extern UINT MSI_RecordCopyField( MSIRECORD *, UINT, MSIRECORD *, UINT ) DECLSPEC
extern MSIRECORD *MSI_CloneRecord( MSIRECORD * ) DECLSPEC_HIDDEN;
extern BOOL MSI_RecordsAreEqual( MSIRECORD *, MSIRECORD * ) DECLSPEC_HIDDEN;
extern BOOL MSI_RecordsAreFieldsEqual(MSIRECORD *a, MSIRECORD *b, UINT field) DECLSPEC_HIDDEN;
extern UINT msi_record_set_string(MSIRECORD *, UINT, const WCHAR *, int) DECLSPEC_HIDDEN;
/* stream internals */
extern void enum_stream_names( IStorage *stg ) DECLSPEC_HIDDEN;
......
......@@ -616,32 +616,47 @@ UINT WINAPI MsiRecordSetStringA( MSIHANDLE handle, UINT iField, LPCSTR szValue )
return ret;
}
UINT MSI_RecordSetStringW( MSIRECORD *rec, UINT iField, LPCWSTR szValue )
static WCHAR *msi_strdupW( const WCHAR *value, int len )
{
LPWSTR str;
WCHAR *ret;
TRACE("%p %d %s\n", rec, iField, debugstr_w(szValue));
if (!(ret = msi_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL;
memcpy( ret, value, len * sizeof(WCHAR) );
ret[len] = 0;
return ret;
}
if( iField > rec->count )
UINT msi_record_set_string( MSIRECORD *rec, UINT field, const WCHAR *value, int len )
{
if (field > rec->count)
return ERROR_INVALID_FIELD;
MSI_FreeField( &rec->fields[iField] );
MSI_FreeField( &rec->fields[field] );
if( szValue && szValue[0] )
if (value && len < 0) len = strlenW( value );
if (value && len)
{
str = strdupW( szValue );
rec->fields[iField].type = MSIFIELD_WSTR;
rec->fields[iField].u.szwVal = str;
rec->fields[field].type = MSIFIELD_WSTR;
rec->fields[field].u.szwVal = msi_strdupW( value, len );
rec->fields[field].len = len;
}
else
{
rec->fields[iField].type = MSIFIELD_NULL;
rec->fields[iField].u.szwVal = NULL;
rec->fields[field].type = MSIFIELD_NULL;
rec->fields[field].u.szwVal = NULL;
rec->fields[field].len = 0;
}
return 0;
}
UINT MSI_RecordSetStringW( MSIRECORD *rec, UINT iField, LPCWSTR szValue )
{
TRACE("%p %d %s\n", rec, iField, debugstr_w(szValue));
return msi_record_set_string( rec, iField, szValue, -1 );
}
UINT WINAPI MsiRecordSetStringW( MSIHANDLE handle, UINT iField, LPCWSTR szValue )
{
MSIRECORD *rec;
......
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