made POSIX compliant
This commit is contained in:
20
src/obiavl.c
20
src/obiavl.c
@ -354,7 +354,8 @@ static char* build_avl_file_name(const char* avl_name)
|
||||
char* file_name;
|
||||
|
||||
// Build the file name
|
||||
if (asprintf(&file_name,"%s.oda", avl_name) < 0)
|
||||
file_name = (char*) malloc((strlen(avl_name) + 5)*sizeof(char));
|
||||
if (sprintf(file_name,"%s.oda", avl_name) < 0)
|
||||
{
|
||||
obi_set_errno(OBI_AVL_ERROR);
|
||||
obidebug(1, "\nError building an AVL tree file name");
|
||||
@ -379,7 +380,8 @@ static char* build_avl_data_file_name(const char* avl_name)
|
||||
char* file_name;
|
||||
|
||||
// Build the file name
|
||||
if (asprintf(&file_name,"%s.odd", avl_name) < 0)
|
||||
file_name = (char*) malloc((strlen(avl_name) + 5)*sizeof(char));
|
||||
if (sprintf(file_name,"%s.odd", avl_name) < 0)
|
||||
{
|
||||
obi_set_errno(OBI_AVL_ERROR);
|
||||
obidebug(1, "\nError building an AVL tree data file name");
|
||||
@ -942,15 +944,20 @@ int obi_avl_exists(OBIDMS_p dms, const char* avl_name)
|
||||
struct stat buffer;
|
||||
char* avl_file_path;
|
||||
char* avl_file_name;
|
||||
char* avl_file_relative_path;
|
||||
int relative_path_size;
|
||||
int check_dir;
|
||||
|
||||
// Build file name
|
||||
// Build the AVL tree file path
|
||||
avl_file_name = build_avl_file_name(avl_name);
|
||||
if (avl_file_name == NULL)
|
||||
return -1;
|
||||
|
||||
// Build the AVL tree file path
|
||||
avl_file_path = get_full_path(dms->avl_dir_fd, avl_file_name);
|
||||
relative_path_size = strlen(avl_file_name) + strlen(AVL_TREES_DIR_NAME) + 2;
|
||||
avl_file_relative_path = (char*) malloc(relative_path_size*sizeof(char));
|
||||
strcpy(avl_file_relative_path, AVL_TREES_DIR_NAME);
|
||||
strcat(avl_file_relative_path, "/");
|
||||
strcat(avl_file_relative_path, avl_file_name);
|
||||
avl_file_path = get_full_path(dms, avl_file_relative_path);
|
||||
if (avl_file_path == NULL)
|
||||
{
|
||||
obidebug(1, "\nError getting the file path for an AVL tree file");
|
||||
@ -961,6 +968,7 @@ int obi_avl_exists(OBIDMS_p dms, const char* avl_name)
|
||||
|
||||
free(avl_file_path);
|
||||
free(avl_file_name);
|
||||
free(avl_file_relative_path);
|
||||
|
||||
if (check_dir == 0)
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user