+
+ new_pollfds = g_try_realloc(session->pollfds, sizeof(GPollFD) * session->num_sources);
+ if (!new_pollfds && session->num_sources > 0) {
+ sr_err("%s: new_pollfds malloc failed", __func__);
+ return SR_ERR_MALLOC;
+ }
+
+ new_sources = g_try_realloc(session->sources, sizeof(struct source) * session->num_sources);
+ if (!new_sources && session->num_sources > 0) {
+ sr_err("%s: new_sources malloc failed", __func__);
+ return SR_ERR_MALLOC;
+ }
+
+ session->pollfds = new_pollfds;
+ session->sources = new_sources;
+
+ return SR_OK;
+}
+
+/**
+ * Remove the source belonging to the specified file descriptor.
+ *
+ * @param fd The file descriptor for which the source should be removed.
+ *
+ * @retval SR_OK Success
+ * @retval SR_ERR_ARG Invalid argument
+ * @retval SR_ERR_MALLOC Memory allocation error.
+ * @retval SR_ERR_BUG Internal error.
+ *
+ * @since 0.3.0
+ */
+SR_API int sr_session_source_remove(struct sr_session *session, int fd)
+{
+ (void) session;
+
+ return _sr_session_source_remove((gintptr)fd);
+}
+
+/**
+ * Remove the source belonging to the specified poll descriptor.
+ *
+ * @param pollfd The poll descriptor for which the source should be removed.
+ *
+ * @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or
+ * SR_ERR_MALLOC upon memory allocation errors, SR_ERR_BUG upon
+ * internal errors.
+ *
+ * @since 0.2.0
+ */
+SR_API int sr_session_source_remove_pollfd(struct sr_session *session,
+ GPollFD *pollfd)
+{
+ (void) session;
+
+ return _sr_session_source_remove((gintptr)pollfd);
+}
+
+/**
+ * Remove the source belonging to the specified channel.
+ *
+ * @param channel The channel for which the source should be removed.
+ *
+ * @retval SR_OK Success.
+ * @retval SR_ERR_ARG Invalid argument.
+ * @retval SR_ERR_MALLOC Memory allocation error.
+ * @return SR_ERR_BUG Internal error.
+ *
+ * @since 0.2.0
+ */
+SR_API int sr_session_source_remove_channel(struct sr_session *session,
+ GIOChannel *channel)
+{
+ (void) session;
+
+ return _sr_session_source_remove((gintptr)channel);