From c74f05eaf5c58530a13003be4fb52e24406f9918 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 21 Dec 2016 16:58:00 -0800 Subject: [PATCH] Rename error enumerator to prevent naming conflicts. --- include/libds.h | 2 +- src/ht.c | 8 ++++---- src/main.c | 4 ++-- src/vec.c | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/libds.h b/include/libds.h index 2ba6506..1561780 100644 --- a/include/libds.h +++ b/include/libds.h @@ -3,7 +3,7 @@ #include -enum libds_result_e { SUCCESS, MALLOC }; +enum libds_result_e { LIBDS_SUCCESS, LIBDS_MALLOC }; typedef enum libds_result_e libds_result; typedef int (*compare_func)(void*, void*); diff --git a/src/ht.c b/src/ht.c index 6106f85..1d52b62 100644 --- a/src/ht.c +++ b/src/ht.c @@ -46,7 +46,7 @@ void ht_free(ht* ht) { } libds_result ht_put(ht* ht, void* key, void* data) { - libds_result result = SUCCESS; + libds_result result = LIBDS_SUCCESS; ht_node* new_node = NULL; unsigned int key_int = ht->hash_func(key) % LIBDS_HT_SIZE; @@ -55,13 +55,13 @@ libds_result ht_put(ht* ht, void* key, void* data) { new_node->data = data; new_node->key = ht->copy_func(key); if (new_node->key == NULL) { - result = MALLOC; + result = LIBDS_MALLOC; } } else { - result = MALLOC; + result = LIBDS_MALLOC; } - if (result != SUCCESS) { + if (result != LIBDS_SUCCESS) { if (new_node) { free(new_node); new_node = NULL; diff --git a/src/main.c b/src/main.c index c15b873..a391cc6 100644 --- a/src/main.c +++ b/src/main.c @@ -19,7 +19,7 @@ int test_vec_basic() { libds_result result = vec_init(&test_vec); vec_free(&test_vec); - return result == SUCCESS; + return result == LIBDS_SUCCESS; } int test_vec_add() { vec test_vec; @@ -27,7 +27,7 @@ int test_vec_add() { int return_code; vec_init(&test_vec); - return_code = vec_add(&test_vec, test_string) == SUCCESS; + return_code = vec_add(&test_vec, test_string) == LIBDS_SUCCESS; if (return_code) return_code = *((void**)test_vec.data) == test_string; vec_free(&test_vec); diff --git a/src/vec.c b/src/vec.c index 6be340a..77e9811 100644 --- a/src/vec.c +++ b/src/vec.c @@ -4,13 +4,13 @@ #include libds_result vec_init(vec* v) { - libds_result result = SUCCESS; + libds_result result = LIBDS_SUCCESS; v->size = 0; v->capacity = LIBDS_VEC_CAPACITY; v->data = calloc(LIBDS_VEC_CAPACITY, sizeof(void*)); if (v->data == NULL) { - result = MALLOC; + result = LIBDS_MALLOC; } return result; @@ -25,7 +25,7 @@ void vec_free(vec* v) { } libds_result vec_add(vec* v, void* data) { - libds_result result = SUCCESS; + libds_result result = LIBDS_SUCCESS; if (v->size >= v->capacity) { void* new_mem = calloc(v->capacity *= 2, sizeof(void*)); if (new_mem) { @@ -33,11 +33,11 @@ libds_result vec_add(vec* v, void* data) { free(v->data); v->data = new_mem; } else { - result = MALLOC; + result = LIBDS_MALLOC; } } - if (result == SUCCESS) { + if (result == LIBDS_SUCCESS) { int index = 0; while (index < v->capacity) { void** data_array = v->data;