Skip to content

Hide impl_data inside struct Dispatcher instead of using opaque pointers in struct Router #46

Description

@oduortoni

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

  1. Eliminate opaque pointers: the compiler can help catch errors at compile time.
  2. 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;
  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions