Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OBITools3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OBITools
OBITools3
Commits
5e0c9f87
Commit
5e0c9f87
authored
Dec 05, 2016
by
Celine Mercier
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the doc for the function building the element names, and a missing
free
parent
852e5488
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
31 deletions
+51
-31
src/obidmscolumn.c
src/obidmscolumn.c
+51
-31
No files found.
src/obidmscolumn.c
View file @
5e0c9f87
...
...
@@ -117,6 +117,23 @@ static obiversion_t obi_get_new_version_number(OBIDMS_column_directory_p column_
static
obiversion_t
create_version_file
(
OBIDMS_column_directory_p
column_directory
);
/**
* @brief Internal function building the default elements names of the lines of a
* column (i.e. "0;1;2;...;n").
*
* @warning The returned pointer has to be freed by the caller.
*
* @param nb_elements_per_line The number of elements per line in the column.
*
* @returns A pointer on the elements names.
* @retval NULL if an error occurred.
*
* @since December 2016
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
static
char
*
build_default_elements_names
(
index_t
nb_elements_per_line
)
/**
* @brief Internal function setting the elements names of the lines of a
* column in the header of the OBIDMS column structure.
...
...
@@ -420,6 +437,36 @@ static obiversion_t create_version_file(OBIDMS_column_directory_p column_directo
}
static
char
*
build_default_elements_names
(
index_t
nb_elements_per_line
)
{
char
*
elements_names
;
int
i
;
elements_names
=
(
char
*
)
malloc
(
ELEMENTS_NAMES_MAX
*
sizeof
(
char
));
if
(
elements_names
==
NULL
)
{
obi_set_errno
(
OBI_MALLOC_ERROR
);
obidebug
(
1
,
"
\n
Error allocating memory for elements names"
);
return
NULL
;
}
if
(
nb_elements_per_line
>
NB_ELTS_MAX_IF_DEFAULT_NAME
)
{
obi_set_errno
(
OBICOL_UNKNOWN_ERROR
);
obidebug
(
1
,
"
\n
Error: too many elements per line to use the default names (max = %d elements)"
,
NB_ELTS_MAX_IF_DEFAULT_NAME
);
return
NULL
;
}
for
(
i
=
0
;
i
<
nb_elements_per_line
;
i
++
)
sprintf
(
elements_names
,
"%d"
,
i
);
// Terminal character
elements_names
[
strlen
(
elements_names
)]
=
'\0'
;
return
elements_names
;
}
int
obi_column_set_elements_names
(
OBIDMS_column_p
column
,
const
char
*
elements_names
)
{
if
(
strlen
(
elements_names
)
>
ELEMENTS_NAMES_MAX
)
...
...
@@ -551,37 +598,6 @@ size_t obi_get_platform_header_size()
}
// TODO
char
*
build_default_elements_names
(
index_t
nb_elements_per_line
)
{
char
*
elements_names
;
int
i
;
elements_names
=
(
char
*
)
malloc
(
ELEMENTS_NAMES_MAX
*
sizeof
(
char
));
if
(
elements_names
==
NULL
)
{
obi_set_errno
(
OBI_MALLOC_ERROR
);
obidebug
(
1
,
"
\n
Error allocating memory for elements names"
);
return
NULL
;
}
if
(
nb_elements_per_line
>
NB_ELTS_MAX_IF_DEFAULT_NAME
)
{
obi_set_errno
(
OBICOL_UNKNOWN_ERROR
);
obidebug
(
1
,
"
\n
Error: too many elements per line to use the default names (max = %d elements)"
,
NB_ELTS_MAX_IF_DEFAULT_NAME
);
return
NULL
;
}
for
(
i
=
0
;
i
<
nb_elements_per_line
;
i
++
)
sprintf
(
elements_names
,
"%d"
,
i
);
// Terminal character
elements_names
[
strlen
(
elements_names
)]
=
'\0'
;
return
elements_names
;
}
OBIDMS_column_p
obi_create_column
(
OBIDMS_p
dms
,
const
char
*
column_name
,
OBIType_t
data_type
,
...
...
@@ -802,6 +818,10 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
obi_column_set_elements_names
(
new_column
,
elements_names
);
// Free the element names if they were built
if
((
elements_names
==
NULL
)
||
(
strcmp
(
elements_names
,
""
)
==
0
))
free
(
elements_names
);
strncpy
(
header
->
name
,
column_name
,
OBIDMS_COLUMN_MAX_NAME
);
if
(
comments
!=
NULL
)
...
...
Celine Mercier
@mercier
mentioned in commit
936be64c
·
Dec 05, 2016
mentioned in commit
936be64c
mentioned in commit 936be64c3468a71d9fbafac96cf2ca68fd8daae1
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment