common/mlx5: add memory management functions