I think at least the attached patch won't hurt (when the DYN_ALLOC part is fixed; and possibly turning that into a MEMSET-like macro).
Just an idea, but couldn't ZEROIFY in the DYN_ALLOC part be defined as free() and subsequent calloc() of the arrays preserving their size?
- Fabian