Assign GPOINTER_TO_INT value before freeing

fixes #375