mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
wbemprox: Store the element size in struct array.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4e71e86747
commit
3995b5ecf9
4 changed files with 33 additions and 31 deletions
|
@ -1251,6 +1251,7 @@ static UINT16 systemenclosure_chassistypes[] =
|
|||
};
|
||||
static const struct array systemenclosure_chassistypes_array =
|
||||
{
|
||||
sizeof(*systemenclosure_chassistypes),
|
||||
ARRAY_SIZE(systemenclosure_chassistypes),
|
||||
&systemenclosure_chassistypes
|
||||
};
|
||||
|
@ -2484,8 +2485,9 @@ static struct array *get_defaultipgateway( IP_ADAPTER_GATEWAY_ADDRESS *list )
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
ret->count = count;
|
||||
ret->ptr = ptr;
|
||||
ret->elem_size = sizeof(*ptr);
|
||||
ret->count = count;
|
||||
ret->ptr = ptr;
|
||||
return ret;
|
||||
}
|
||||
static struct array *get_dnsserversearchorder( IP_ADAPTER_DNS_SERVER_ADDRESS *list )
|
||||
|
@ -2517,8 +2519,9 @@ static struct array *get_dnsserversearchorder( IP_ADAPTER_DNS_SERVER_ADDRESS *li
|
|||
}
|
||||
if ((p = wcsrchr( ptr[i - 1], ':' ))) *p = 0;
|
||||
}
|
||||
ret->count = count;
|
||||
ret->ptr = ptr;
|
||||
ret->elem_size = sizeof(*ptr);
|
||||
ret->count = count;
|
||||
ret->ptr = ptr;
|
||||
return ret;
|
||||
}
|
||||
static struct array *get_ipaddress( IP_ADAPTER_UNICAST_ADDRESS_LH *list )
|
||||
|
@ -2549,8 +2552,9 @@ static struct array *get_ipaddress( IP_ADAPTER_UNICAST_ADDRESS_LH *list )
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
ret->count = count;
|
||||
ret->ptr = ptr;
|
||||
ret->elem_size = sizeof(*ptr);
|
||||
ret->count = count;
|
||||
ret->ptr = ptr;
|
||||
return ret;
|
||||
}
|
||||
static struct array *get_ipsubnet( IP_ADAPTER_UNICAST_ADDRESS_LH *list )
|
||||
|
@ -2601,8 +2605,9 @@ static struct array *get_ipsubnet( IP_ADAPTER_UNICAST_ADDRESS_LH *list )
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
ret->count = count;
|
||||
ret->ptr = ptr;
|
||||
ret->elem_size = sizeof(*ptr);
|
||||
ret->count = count;
|
||||
ret->ptr = ptr;
|
||||
return ret;
|
||||
}
|
||||
static WCHAR *get_settingid( UINT32 index )
|
||||
|
@ -3458,20 +3463,20 @@ static WCHAR *get_accountname( LSA_TRANSLATED_NAME *name )
|
|||
}
|
||||
static struct array *get_binaryrepresentation( PSID sid, UINT len )
|
||||
{
|
||||
struct array *array = heap_alloc( sizeof(struct array) );
|
||||
if (array)
|
||||
struct array *ret;
|
||||
UINT8 *ptr;
|
||||
|
||||
if (!(ret = heap_alloc( sizeof(*ret) ))) return NULL;
|
||||
if (!(ptr = heap_alloc( len )))
|
||||
{
|
||||
UINT8 *ret = heap_alloc( len );
|
||||
if (ret)
|
||||
{
|
||||
memcpy( ret, sid, len );
|
||||
array->count = len;
|
||||
array->ptr = ret;
|
||||
return array;
|
||||
}
|
||||
heap_free( array );
|
||||
heap_free( ret );
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
memcpy( ptr, sid, len );
|
||||
ret->elem_size = sizeof(*ptr);
|
||||
ret->count = len;
|
||||
ret->ptr = ptr;
|
||||
return ret;
|
||||
}
|
||||
static WCHAR *get_referenceddomainname( LSA_REFERENCED_DOMAIN_LIST *domain )
|
||||
{
|
||||
|
|
|
@ -235,13 +235,11 @@ static struct record *create_record( struct table *table )
|
|||
|
||||
void destroy_array( struct array *array, CIMTYPE type )
|
||||
{
|
||||
UINT i, size;
|
||||
|
||||
UINT i;
|
||||
if (!array) return;
|
||||
if (type == CIM_STRING || type == CIM_DATETIME || type == CIM_REFERENCE)
|
||||
{
|
||||
size = get_type_size( type );
|
||||
for (i = 0; i < array->count; i++) heap_free( *(WCHAR **)((char *)array->ptr + i * size) );
|
||||
for (i = 0; i < array->count; i++) heap_free( *(WCHAR **)((char *)array->ptr + i * array->elem_size) );
|
||||
}
|
||||
heap_free( array->ptr );
|
||||
heap_free( array );
|
||||
|
|
|
@ -765,7 +765,6 @@ VARTYPE to_vartype( CIMTYPE type )
|
|||
SAFEARRAY *to_safearray( const struct array *array, CIMTYPE type )
|
||||
{
|
||||
SAFEARRAY *ret;
|
||||
UINT size = get_type_size( type );
|
||||
VARTYPE vartype = to_vartype( type );
|
||||
LONG i;
|
||||
|
||||
|
@ -773,7 +772,7 @@ SAFEARRAY *to_safearray( const struct array *array, CIMTYPE type )
|
|||
|
||||
for (i = 0; i < array->count; i++)
|
||||
{
|
||||
void *ptr = (char *)array->ptr + i * size;
|
||||
void *ptr = (char *)array->ptr + i * array->elem_size;
|
||||
if (vartype == VT_BSTR)
|
||||
{
|
||||
BSTR str = SysAllocString( *(const WCHAR **)ptr );
|
||||
|
@ -951,23 +950,22 @@ static struct array *to_array( VARIANT *var, CIMTYPE *type )
|
|||
LONG bound, i;
|
||||
VARTYPE vartype;
|
||||
CIMTYPE basetype;
|
||||
UINT size;
|
||||
|
||||
if (SafeArrayGetVartype( V_ARRAY( var ), &vartype ) != S_OK) return NULL;
|
||||
if (!(basetype = to_cimtype( vartype ))) return NULL;
|
||||
if (SafeArrayGetUBound( V_ARRAY( var ), 1, &bound ) != S_OK) return NULL;
|
||||
if (!(ret = heap_alloc( sizeof(struct array) ))) return NULL;
|
||||
|
||||
ret->count = bound + 1;
|
||||
size = get_type_size( basetype );
|
||||
if (!(ret->ptr = heap_alloc_zero( ret->count * size )))
|
||||
ret->count = bound + 1;
|
||||
ret->elem_size = get_type_size( basetype );
|
||||
if (!(ret->ptr = heap_alloc_zero( ret->count * ret->elem_size )))
|
||||
{
|
||||
heap_free( ret );
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < ret->count; i++)
|
||||
{
|
||||
void *ptr = (char *)ret->ptr + i * size;
|
||||
void *ptr = (char *)ret->ptr + i * ret->elem_size;
|
||||
if (vartype == VT_BSTR)
|
||||
{
|
||||
BSTR str;
|
||||
|
|
|
@ -124,6 +124,7 @@ struct property
|
|||
|
||||
struct array
|
||||
{
|
||||
UINT elem_size;
|
||||
UINT count;
|
||||
void *ptr;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue