size_t maxn = store->maxn;
void *tmp;
- if (n >= maxn) {
+ // one more item for the array ending shouldn't be needed,
+ // only preventively here
+ if (n + 1 >= maxn) {
maxn = maxn ? maxn << 1 : 256;
- if ((tmp = realloc(store->jobs, maxn * sizeof(*store->jobs))) == NULL)
+ if ((tmp = realloc(store->jobs, (maxn + 1) * sizeof(*store->jobs))) == NULL)
return edg_wll_SetError(ctx, errno ? : ENOMEM, NULL);
store->jobs = tmp;
if (!(store->flags & EDG_WLL_STAT_NO_STATES)) {
- if ((tmp = realloc(store->states, maxn * sizeof(*store->states))) == NULL)
+ if ((tmp = realloc(store->states, (maxn + 1) * sizeof(*store->states))) == NULL)
return edg_wll_SetError(ctx, errno ? : ENOMEM, NULL);
store->states = tmp;
}
store->maxn = maxn;
}
+
store->jobs[n] = jobid;
+ store->jobs[n + 1] = NULL;
+
if (!(store->flags & EDG_WLL_STAT_NO_STATES)) {
if (status) store->states[n] = *status;
else memset(&store->states[n], 0, sizeof(*store->states));
+ memset(&store->states[n + 1], 0, sizeof(*store->states));
}
store->n++;
}
}
+cleanup:
// finish
cb(ctx, NULL, NULL, data);
-cleanup:
free(qbase);
free(state_where);
free(tags_where);