This function returns 0 if successful. Otherwise, it returns ENOMEM indicating that no memory could be allocated for the callback.