Parcourir la source

list: Use enums for FAUX_LIST_SORTED, FAUX_LIST_UNIQUE

Serj Kalichev il y a 4 ans
Parent
commit
b19fc4d119
4 fichiers modifiés avec 19 ajouts et 7 suppressions
  1. 1 1
      faux/ini/ini.c
  2. 11 1
      faux/list.h
  3. 3 3
      faux/list/list.c
  4. 4 2
      testc/testc.c

+ 1 - 1
faux/ini/ini.c

@@ -30,7 +30,7 @@ faux_ini_t *faux_ini_new(void) {
 		return NULL;
 
 	// Init
-	ini->list = faux_list_new(BOOL_TRUE, BOOL_TRUE, 
+	ini->list = faux_list_new(FAUX_LIST_SORTED, FAUX_LIST_UNIQUE,
 		faux_pair_compare, faux_pair_kcompare, faux_pair_free);
 
 	return ini;

+ 11 - 1
faux/list.h

@@ -9,6 +9,16 @@
 
 #include "faux.h"
 
+typedef enum {
+	FAUX_LIST_SORTED = BOOL_TRUE,
+	FAUX_LIST_UNSORTED = BOOL_FALSE
+	} faux_list_sorted_t;
+
+typedef enum {
+	FAUX_LIST_UNIQUE = BOOL_TRUE,
+	FAUX_LIST_NONUNIQUE = BOOL_FALSE
+	} faux_list_unique_t;
+
 typedef struct faux_list_node_s faux_list_node_t;
 typedef struct faux_list_s faux_list_t;
 
@@ -28,7 +38,7 @@ void *faux_list_each(faux_list_node_t **iter);
 void *faux_list_eachr(faux_list_node_t **iter);
 
 // list_t methods
-faux_list_t *faux_list_new(bool_t sorted, bool_t unique,
+faux_list_t *faux_list_new(faux_list_sorted_t sorted, faux_list_unique_t unique,
 	faux_list_cmp_fn cmpFn, faux_list_kcmp_fn kcmpFn,
 	faux_list_free_fn freeFn);
 void faux_list_free(faux_list_t *list);

+ 3 - 3
faux/list/list.c

@@ -190,14 +190,14 @@ void *faux_list_eachr(faux_list_node_t **iter) {
  * void faux_list_free_fn(void *data);
  * @endcode
  *
- * @param [in] sorted If list is sorted - BOOL_TRUE, unsorted - BOOL_FALSE.
- * @param [in] unique If list entry is unique - BOOL_TRUE, else - BOOL_FALSE.
+ * @param [in] sorted If list is sorted - FAUX_LIST_SORTED, unsorted - FAUX_LIST_UNSORTED.
+ * @param [in] unique If list entry is unique - FAUX_LIST_UNIQUE, else - FAUX_LIST_NONUNIQUE.
  * @param [in] compareFn Callback function to compare two user data instances
  * to sort list.
  * @param [in] freeFn Callback function to free user data.
  * @return Newly created bidirectional list or NULL on error.
  */
-faux_list_t *faux_list_new(bool_t sorted, bool_t unique,
+faux_list_t *faux_list_new(faux_list_sorted_t sorted, faux_list_unique_t unique,
 	faux_list_cmp_fn cmpFn, faux_list_kcmp_fn kcmpFn,
 	faux_list_free_fn freeFn) {
 

+ 4 - 2
testc/testc.c

@@ -318,7 +318,9 @@ int main(int argc, char *argv[]) {
 				continue;
 			}
 
-			buf_list = faux_list_new(BOOL_FALSE, BOOL_FALSE, NULL, NULL, (void (*)(void *))faux_chunk_free);
+			buf_list = faux_list_new(
+				FAUX_LIST_UNSORTED, FAUX_LIST_NONUNIQUE,
+				NULL, NULL, (void (*)(void *))faux_chunk_free);
 
 			// Execute testing function
 			wstatus = exec_test(test_sym, buf_list);
@@ -503,7 +505,7 @@ static opts_t *opts_new(void) {
 	opts->debug = BOOL_FALSE;
 
 	// Members of list are static strings from argv so don't free() it
-	opts->so_list = faux_list_new(BOOL_FALSE, BOOL_TRUE,
+	opts->so_list = faux_list_new(FAUX_LIST_UNSORTED, FAUX_LIST_UNIQUE,
 		(faux_list_cmp_fn)strcmp, NULL, NULL);
 	if (!opts->so_list) {
 		opts_free(opts);