-
Notifications
You must be signed in to change notification settings - Fork 0
/
float_range.c
41 lines (31 loc) · 1.13 KB
/
float_range.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include"strglob.h"
/*!
* @fn void float_range(const FLOAT_RANGE *const frang, STR_GLOB *restrict ugfrn)
*
* @brief create a `float` array for each value in the desired floating point range
*
* @details the `out` member of the `ugfrn` structure is assigned an array of strings instead of a value being returned
*
* @param [in] frang structure containing the begrt and end of the floating-point range
* @param [out] ugfrn the current element of the glob string's linked list that is being operated on
*
* @see cons_float2str
*/
void float_range(const FLOAT_RANGE *const frang, STR_GLOB *restrict ugfrn) {
assert(frang);
assert(ugfrn);
register size_t szrgs = 1;
for(register const FLOAT_RANGE *frs = frang;frs && frs->beg;++frs) {
szrgs += (frs->end- frs->beg);
szrgs++;
}
ugfrn->out = malloc(szrgs * sizeof(*(ugfrn->out)));
if(!ugfrn->out)
exit_verbose("malloc", __FILE__, __LINE__);
register char **pp = ugfrn->out;
for(register const FLOAT_RANGE *frp = frang;frp && frp->beg;++frp)
for(register int c = frp->beg;c <= frp->end;++c)
*pp++ = cons_float2str(c);
*pp = NULL;
return;
}