23 |
|
|
24 |
#include "subclist.h" |
#include "subclist.h" |
25 |
#include <stdlib.h> |
#include <stdlib.h> |
26 |
|
#include "xalloc.h" |
27 |
|
|
28 |
/* I call these objects `lists' but they are in fact simple dynamic arrays */ |
/* I call these objects `lists' but they are in fact simple dynamic arrays */ |
29 |
|
|
33 |
void |
void |
34 |
subc_list_double_create(subc_list_double *l) |
subc_list_double_create(subc_list_double *l) |
35 |
{ |
{ |
36 |
l->data = (double *) malloc(CHUNKSIZE * sizeof (double)); |
l->data = xnmalloc (CHUNKSIZE, sizeof *l->data); |
37 |
l->sz = CHUNKSIZE; |
l->sz = CHUNKSIZE; |
38 |
l->n_data = 0; |
l->n_data = 0; |
39 |
} |
} |
47 |
if (l->n_data >= l->sz ) |
if (l->n_data >= l->sz ) |
48 |
{ |
{ |
49 |
l->sz += CHUNKSIZE; |
l->sz += CHUNKSIZE; |
50 |
l->data = realloc(l->data, l->sz * sizeof(double)); |
l->data = xnrealloc (l->data, l->sz, sizeof *l->data); |
51 |
} |
} |
52 |
|
|
53 |
} |
} |