11.05.2021 15:28, Paolo Bonzini wrote:
On 10/05/21 13:28, Vladimir Sementsov-Ogievskiy wrote:
Could we instead add a c file and add the structure private? Then we'll have
progress_new() and progress_free() APIs instead.
This way, it would be a lot simpler to control that nobady use structure fields
directly.
I don't know... I prefer embedding structs to heap allocation.
I agree that embedding looks better from allocation point of view.. But IMHO
encapsulation guarantee of private structure is better feature. Especially when
we have getter/setter methods. Even the patch itself is example: to review this
carefully, I should somehow check that every use of the structure is updated
(grepping the code, or maybe change field name and recompile, to catch every
occurrence of it).. And if patch makes structure private and adds
setters/getters, it can be reviewed without applying.
And we have to call _init/_destroy anyway, so it's not more complex to call
_new/_free instead.
--
Best regards,
Vladimir