On 12/1/20 3:00 PM, Zebediah Figura (she/her) wrote:
+HRESULT mfplat_DllRegisterServer(void) +{
- unsigned int i;
- HRESULT hr;
- for (i = 0; i < ARRAY_SIZE(mfts); i++)
- {
const struct mft *cur = &mfts[i];
MFT_REGISTER_TYPE_INFO *input_types, *output_types;
input_types = heap_alloc(cur->input_types_count * sizeof(input_types[0]));
output_types = heap_alloc(cur->output_types_count * sizeof(output_types[0]));
Separately, I think it'd be better just to use MFT_REGISTER_TYPE_INFO directly in your "struct mft", and avoid allocation. It'd have to be non-const (or duplicate GUID definitions), but I think that's less awkward on the whole.
I'm trying to implement this now, but I'm having trouble with it. MFT_REGISTER_TYPE_INFO consists of GUID value fields, not GUID pointer fields. I'm not sure if there's a clean way to fill GUID fields of a struct in an initialization list, even when the array is not const. I definitely don't want to duplicate the GUID definitions, that would be ugly. Also, I'm not sure I necessarily I agree this solution is better than just having some heap allocations in DllRegisterServer, it's not in what I would call a hotpath.