Browse Source

faux.list: faux_list_is_empty()

Serj Kalichev 3 years ago
parent
commit
464c2f0f8d
3 changed files with 22 additions and 0 deletions
  1. 3 0
      faux/ini/ini.c
  2. 1 0
      faux/list.h
  3. 18 0
      faux/list/list.c

+ 3 - 0
faux/ini/ini.c

@@ -493,3 +493,6 @@ bool_t faux_ini_write_file(const faux_ini_t *ini, const char *fn)
 
 	return BOOL_TRUE;
 }
+
+
+//faux_ini_t *

+ 1 - 0
faux/list.h

@@ -46,6 +46,7 @@ void faux_list_free(faux_list_t *list);
 faux_list_node_t *faux_list_head(const faux_list_t *list);
 faux_list_node_t *faux_list_tail(const faux_list_t *list);
 size_t faux_list_len(const faux_list_t *list);
+size_t faux_list_is_empty(const faux_list_t *list);
 
 faux_list_node_t *faux_list_add(faux_list_t *list, void *data);
 faux_list_node_t *faux_list_add_find(faux_list_t *list, void *data);

+ 18 - 0
faux/list/list.c

@@ -314,6 +314,24 @@ size_t faux_list_len(const faux_list_t *list)
 }
 
 
+/** @brief Checks is list empty.
+ *
+ * @param [in] list Allocated list.
+ * @return BOOL_TRUE - empty, BOOL_FALSE - not empty.
+ */
+size_t faux_list_is_empty(const faux_list_t *list)
+{
+	assert(list);
+	if (!list)
+		return BOOL_TRUE;
+
+	if (faux_list_len(list) == 0)
+		return BOOL_TRUE;
+
+	return BOOL_FALSE;
+}
+
+
 /** @brief Generic static function for adding new list nodes.
  *
  * @param [in] list List to add node to.