Browse Source

faux.net: faux_pollfd_del_all()

Serj Kalichev 2 years ago
parent
commit
d0510aa1f1
3 changed files with 19 additions and 0 deletions
  1. 1 0
      faux/faux.map
  2. 1 0
      faux/net.h
  3. 17 0
      faux/net/pollfd.c

+ 1 - 0
faux/faux.map

@@ -235,6 +235,7 @@ FAUX_2.0 {
 		faux_pollfd_init_iterator;
 		faux_pollfd_each;
 		faux_pollfd_each_active;
+		faux_pollfd_del_all;
 
 		faux_ev_new;
 		faux_ev_free;

+ 1 - 0
faux/net.h

@@ -69,6 +69,7 @@ bool_t faux_pollfd_del_by_index(faux_pollfd_t *faux_pollfd, unsigned int index);
 void faux_pollfd_init_iterator(faux_pollfd_t *faux_pollfd, faux_pollfd_iterator_t *iterator);
 struct pollfd *faux_pollfd_each(faux_pollfd_t *faux_pollfd, faux_pollfd_iterator_t *iterator);
 struct pollfd *faux_pollfd_each_active(faux_pollfd_t *faux_pollfd, faux_pollfd_iterator_t *iterator);
+bool_t faux_pollfd_del_all(faux_pollfd_t *faux_pollfd);
 
 C_DECL_END
 

+ 17 - 0
faux/net/pollfd.c

@@ -294,3 +294,20 @@ struct pollfd *faux_pollfd_each_active(faux_pollfd_t *faux_pollfd, faux_pollfd_i
 
 	return NULL;
 }
+
+
+/** @brief Deletes all items from pollfd object.
+ *
+ * @param [in] faux_pollfd Allocated faux_pollfd_t object.
+ * @return BOOL_TRUE - success, BOOL_FALSE on error.
+ */
+bool_t faux_pollfd_del_all(faux_pollfd_t *faux_pollfd)
+{
+	assert(faux_pollfd);
+	if (!faux_pollfd)
+		return BOOL_FALSE;
+
+	faux_vec_del_all(faux_pollfd->vec);
+
+	return BOOL_TRUE;
+}