Esme Povirk (@madewokherd) commented about dlls/uiautomationcore/uia_com_client.c:
- *out_arr = NULL;
- hr = SafeArrayGetVartype(sa, &vt);
- if (FAILED(hr))
return hr;
- if (vt != VT_I4)
return E_INVALIDARG;
- hr = get_safearray_bounds(sa, &lbound, &elems);
- if (FAILED(hr))
return hr;
- if (!(arr = CoTaskMemAlloc(elems * sizeof(int))))
return E_OUTOFMEMORY;
- for (i = 0; i < elems; i++)
I'd expect that a memcpy would be faster and no more complex than this.