libkmod/libkmod-signature: rework struct kmod_signature_info
Currently, we use a stack allocated instance which bolts of misc private
data via a void *, while also having an optional free callback.
In kmod we opt to pre-calculate the total size, do a one-off allocation,
copy the data as needed, adjusting the pointers.
Doing the same here, gives us a mixed bag of benefits:
- shorter and simpler code
- smaller binary - ~100 bytes off
- fewer instructions - ~40 per module
- few allocations - ~2 per module
- extra bytes are allocated - ~180 per module
The updated code seems far more natural and consistent with the
code-base. Although, if we really want to squeeze more cycles we could
use a reasonably large stack buffer and fallback to heap.
v2:
- don't leak on d2i_PKCS7_bio failure
- use +1 (instead of sizeof('\0')) for the null terminator
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/427
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>