[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 19/22] tools/utils: add pointer to in-progress settings to CfgParseContext
Rather than needing the full structure, for many operations the settings pointer is enough. Signed-off-by: Elliott Mitchell <ehem+xen@xxxxxxx> --- tools/libs/util/libxlu_cfg.c | 13 ++++++++----- tools/libs/util/libxlu_cfg_y.y | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/libs/util/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c index 91e056bb33..3c0703f9df 100644 --- a/tools/libs/util/libxlu_cfg.c +++ b/tools/libs/util/libxlu_cfg.c @@ -67,10 +67,13 @@ XLU_Config *xlu_cfg_init(FILE *report, const char *report_source) { return cfg; } -static int ctx_prep(CfgParseContext *ctx, XLU_Config *cfg) { +static int ctx_prep(CfgParseContext *ctx, XLU_Config *cfg, + XLU_ConfigSetting **psettings) +{ int e; ctx->cfg= cfg; + ctx->psettings = psettings; ctx->err= 0; ctx->lexerrlineno= -1; ctx->likely_python= 0; @@ -112,7 +115,7 @@ int xlu_cfg_readfile(XLU_Config *cfg, const char *real_filename) { int e; CfgParseContext ctx; - e = ctx_prep(&ctx, cfg); + e = ctx_prep(&ctx, cfg, &cfg->settings); if (e) { ctx.err= e; goto xe; } f= fopen(real_filename, "r"); @@ -139,7 +142,7 @@ int xlu_cfg_readdata(XLU_Config *cfg, const char *data, int length) { YY_BUFFER_STATE buf= 0; CfgParseContext ctx; - e= ctx_prep(&ctx, cfg); + e = ctx_prep(&ctx, cfg, &cfg->settings); if (e) { ctx.err= e; goto xe; } buf = xlu__cfg_yy_scan_bytes(data, length, ctx.scanner); @@ -619,8 +622,8 @@ void xlu__cfg_set_store(CfgParseContext *ctx, char *name, set->value = val; set->op = op; set->lineno= lineno; - set->next= ctx->cfg->settings; - ctx->cfg->settings= set; + set->next = *ctx->psettings; + *ctx->psettings = set; return; out: assert(ctx->err); diff --git a/tools/libs/util/libxlu_cfg_y.y b/tools/libs/util/libxlu_cfg_y.y index 5c7e31222d..5bd4cbb0ab 100644 --- a/tools/libs/util/libxlu_cfg_y.y +++ b/tools/libs/util/libxlu_cfg_y.y @@ -21,6 +21,7 @@ typedef struct { XLU_Config *cfg; + XLU_ConfigSetting **psettings; int err, lexerrlineno, likely_python; void *scanner; } CfgParseContext; -- (\___(\___(\______ --=> 8-) EHM <=-- ______/)___/)___/) \BS ( | ehem+sigmsg@xxxxxxx PGP 87145445 | ) / \_CS\ | _____ -O #include <stddisclaimer.h> O- _____ | / _/ 8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |