mesa: extract helper function from _mesa_GetPointerv