/* make sure no memory from previous parse attempts is leaked */
uci_file_cleanup(ctx);
- pctx = (struct uci_parse_context *) uci_malloc(ctx, sizeof(struct uci_parse_context));
- ctx->pctx = pctx;
+ uci_alloc_parse_context(ctx);
+ pctx = ctx->pctx;
pctx->file = stream;
if (*package && single) {
pctx->package = *package;
/* freed together with the uci_package */
path = NULL;
- /* check for updated history, just in case */
+ /* check for updated history, flush */
uci_load_history(ctx, p, true);
} else {
/* flush history */