MAINT: linalg: use sizeof instead of magic constant

Allows changing the error message at some point.
ENH: Speed up `unique` with `return_inverse`

This replaces a sort with fancy indexing.
Merge pull request #5012 from jaimefrio/faster_return_inverse

ENH: Speed up `unique` with `return_inverse`
BUG: potential memset on NULL in allocator cache
Merge pull request #5013 from larsmans/c-fixes

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