-
Notifications
You must be signed in to change notification settings - Fork 0
/
cons_glob2ints.c
42 lines (33 loc) · 931 Bytes
/
cons_glob2ints.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
42
#include"strglob.h"
/*! @fn int **cons_glob2ints(STR_GLOB *stgl)
*
* @param [in] stgl the head element of the glob list
*
* @return an array of integer arrays containing whole number sequences from 1 to that element's `tot` member
*
* @brief compute an integer array corresponding to each glob list element
*
* @details create an array based on the tot element of each glob list element
*
* @see enum_intseq
*/
int **cons_glob2ints(STR_GLOB *stgl) {
register STR_GLOB *restrict stgp = stgl;
register size_t innx = 1; /* inner count */
int **pias = NULL;
while(stgp) {
innx++;
stgp = stgp->next;
}
pias = malloc(innx * sizeof *pias);
if(!pias)
exit_verbose("malloc", __FILE__, __LINE__);
stgp = stgl;
innx = 0;
while(stgp) {
pias[innx++] = enum_intseq(stgp->tot);
stgp = stgp->next;
}
pias[innx] = 0;
return pias;
}