Closed liskar-dev closed 1 week ago
IIRC it was mainly to signal that we will free the things inside the struct, but we will not free the struct itself. I don't think this is a really critical distinction though. Do you have a particular reason you think they should take pointers instead? (I do agree it feels a bit odd.)
My understanding is that C APIs don't generally take raw structs due to inconsistencies between various ABIs making it a nightmare. It's probably fine:tm: on x86/ARM64 but for more niche architectures it's simpler/better defined to just take pointers for everything. And it doesn't matter for perf anyways in practice.
Ah yes, I forgot about that. I did some research before on this topic - e.g. https://www.reddit.com/r/C_Programming/comments/19cdr0e/abi_safety_of_passing_small_struct_by_value/ - and as far as I could tell it shouldn't be that much of a concern in this decade, and avoiding it is maybe too paranoid. To some extent we have to rely on the compiler to work correctly... and I have a hard time imagining webgpu.h would actually be used on any systems that don't even have well-maintained compilers.
Nov 21 meeting:
These function definitions seem to take whole structs by value. Why is it so? Was this intentional? Am I missing something?