MAINT: linalg: use sizeof instead of magic constant

Allows changing the error message at some point.
BUG: potential memset on NULL in allocator cache
Merge pull request #5013 from larsmans/c-fixes

Small fixes, including a memset(NULL, c, n)