mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
csv and villas.human formats: remove dynamic memory allocation
This commit is contained in:
parent
9e5852233c
commit
a74644cea9
2 changed files with 2 additions and 4 deletions
|
@ -113,7 +113,7 @@ static size_t csv_sscan_single(struct io *io, const char *buf, size_t len, struc
|
|||
next_seperator = strchr(ptr, io->delimiter);
|
||||
}
|
||||
|
||||
char *number = malloc(next_seperator - ptr);
|
||||
char number[100];
|
||||
strncpy(number, ptr, next_seperator-ptr);
|
||||
char * contains_dot = strstr(number, ".");
|
||||
if(contains_dot == NULL){
|
||||
|
@ -127,7 +127,6 @@ static size_t csv_sscan_single(struct io *io, const char *buf, size_t len, struc
|
|||
s->data[s->length].f = strtod(ptr, &end);
|
||||
sample_set_data_format(s, s->length, SAMPLE_DATA_FORMAT_FLOAT);
|
||||
}
|
||||
free(number);
|
||||
|
||||
|
||||
/* There are no valid values anymore. */
|
||||
|
|
|
@ -138,7 +138,7 @@ static size_t villas_human_sscan_single(struct io *io, const char *buf, size_t l
|
|||
next_seperator = strchr(ptr, io->delimiter);
|
||||
}
|
||||
|
||||
char *number = malloc(next_seperator - ptr);
|
||||
char number[100];
|
||||
strncpy(number, ptr, next_seperator-ptr);
|
||||
char * contains_dot = strstr(number, ".");
|
||||
if(contains_dot == NULL){
|
||||
|
@ -152,7 +152,6 @@ static size_t villas_human_sscan_single(struct io *io, const char *buf, size_t l
|
|||
s->data[s->length].f = strtod(ptr, &end);
|
||||
sample_set_data_format(s, s->length, SAMPLE_DATA_FORMAT_FLOAT);
|
||||
}
|
||||
free(number);
|
||||
|
||||
/* There are no valid values anymore. */
|
||||
if (end == ptr)
|
||||
|
|
Loading…
Add table
Reference in a new issue