apply

Details on parameters and result can be found here.

Note that it is the responsibility of the cursor allocator to deallocate it.