Hide impl_data inside struct Dispatcher instead of using opaque pointers.
Currently, impl_data is a purely internal structure for const Dispatcher. Instead of exposing it as a void pointer (void *). We should hide it inside the struct Dispatcher.
Benefits
- Eliminate opaque pointers: the compiler can help catch errors at compile time.
- Maintain type safety: casting struct RegexDispatcher* to struct Dispatcher* only risks alignment issues, which can be fixed with:
#include <stddef.h>
max_align_t __dummy_field_for_alignment;
- Cleaner design — base Dispatcher handles the interface, specialized dispatchers manage their own data internally.
This approach allows internal data to remain private while still benefiting from strong typing and compiler checks.
Hide impl_data inside struct Dispatcher instead of using opaque pointers.
Currently, impl_data is a purely internal structure for const Dispatcher. Instead of exposing it as a void pointer (void *). We should hide it inside the struct Dispatcher.
Benefits
This approach allows internal data to remain private while still benefiting from strong typing and compiler checks.