}
if (num_candidates == 0) {
- *size = 0;
free(ctx.states);
return false;
}
num_candidates = candidate_idx;
if (num_candidates == 0) {
- *size = 0;
free(ctx.states);
free(candidates);
return false;
* divided by size.
*/
- if (total_size > options->preamble_storage_size) {
- qsort(candidates, num_candidates, sizeof(*candidates), candidate_sort);
+ if (((*size) + total_size) > options->preamble_storage_size) {
+ qsort(candidates, num_candidates, sizeof(*candidates), candidate_sort);
}
- unsigned offset = 0;
+ unsigned offset = *size;
for (unsigned i = 0; i < num_candidates; i++) {
def_state *state = candidates[i];
offset = ALIGN_POT(offset, state->align);