lib/c: move up general logic from `CIntArray` to `CArray`