Consider that I’ve implemented SHA-256 hashing in C as incrementally updated IUF (init-update-finalize) working context and 3 subroutines. To efficiently use it in multi-threaded applications, users may want to avoid heap allocation using malloc
or calloc
, etc. and declare the working context on the stack using a structure type I’ve provided in the header.
With such setup, I’ll have to either use 2 headers – 1 for the user to include and provide only opaque definition, 1 for implementation with the implmentation details, or expose the implementation details of the working context in the header. Q Doesn’t the former make it harder to maintain the code? and doesn’t the latter break the abstraction?