[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [freehaven-dev] Simulation
Array reallocation in C:
{
somestruct
*s;
s = malloc(
sizeof(somestruct) * num_of_elements );
/* use s like you would
any array */
s[index].field =
0;
/* later, make the s array
bigger, but keep the existing values.
note
that the realloc'd size is the total of old size + desired
new
elements */
s = realloc(s,
(sizeof(somestruct) * new_num_of_elements));
}