refactor id_gen

- handles case where alloc callback may be null