Make get_raw_samples() use provided mem instead of allocating