Rename error enumerator to prevent naming conflicts.

This commit is contained in:
Danila Fedorin 2016-12-21 16:58:00 -08:00
parent 8ac71dc021
commit c74f05eaf5
4 changed files with 12 additions and 12 deletions

View File

@ -3,7 +3,7 @@
#include <stdarg.h>
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*);

View File

@ -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;

View File

@ -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);

View File

@ -4,13 +4,13 @@
#include <string.h>
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;