1
0
Fork 0
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:
Sonja Kolen 2018-08-01 16:45:54 +02:00
parent 9e5852233c
commit a74644cea9
2 changed files with 2 additions and 4 deletions

View file

@ -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. */

View file

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