diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-10-17 20:15:23 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-10-23 18:17:02 -0700 |
commit | d508a16aca91b521719d929cd59db381c44cd7ad (patch) | |
tree | af076eb66fcd4002a01a29a46f8b80d4d4129994 /core/save-xml.c | |
parent | b9b51ffd4ebd14e085bef69ee0daf6a1927cc960 (diff) | |
download | subsurface-d508a16aca91b521719d929cd59db381c44cd7ad.tar.gz |
parser: replace params[] code by new xml_params struct
This fixes a load of memory holes, and makes the code
(hopefully) more readable.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/save-xml.c')
-rw-r--r-- | core/save-xml.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/core/save-xml.c b/core/save-xml.c index 6da9a7528..812201e48 100644 --- a/core/save-xml.c +++ b/core/save-xml.c @@ -29,6 +29,7 @@ #include "qthelper.h" #include "gettext.h" #include "tag.h" +#include "xmlparams.h" /* * We're outputting utf8 in xml. @@ -834,17 +835,24 @@ int save_dives_logic(const char *filename, const bool select_only, bool anonymiz return error; } + +static int export_dives_xslt_doit(const char *filename, struct xml_params *params, bool selected, int units, const char *export_xslt, bool anonymize); int export_dives_xslt(const char *filename, const bool selected, const int units, const char *export_xslt, bool anonymize) { + struct xml_params *params = alloc_xml_params(); + int ret = export_dives_xslt_doit(filename, params, selected, units, export_xslt, anonymize); + free_xml_params(params); + return ret; +} + +static int export_dives_xslt_doit(const char *filename, struct xml_params *params, bool selected, int units, const char *export_xslt, bool anonymize) +{ FILE *f; struct membuffer buf = { 0 }; xmlDoc *doc; xsltStylesheetPtr xslt = NULL; xmlDoc *transformed; int res = 0; - char *params[3]; - int pnr = 0; - char unitstr[3]; if (verbose) fprintf(stderr, "export_dives_xslt with stylesheet %s\n", export_xslt); @@ -870,12 +878,9 @@ int export_dives_xslt(const char *filename, const bool selected, const int units if (!xslt) return report_error("Failed to open export conversion stylesheet"); - snprintf(unitstr, 3, "%d", units); - params[pnr++] = "units"; - params[pnr++] = unitstr; - params[pnr++] = NULL; + xml_params_add_int(params, "units", units); - transformed = xsltApplyStylesheet(xslt, doc, (const char **)params); + transformed = xsltApplyStylesheet(xslt, doc, xml_params_get(params)); xmlFreeDoc(doc); /* Write the transformed export to file */ |