commit d00519f1bf8cb76d2049939cd64dc9c096dc8776
parent bcf9f3c7ade0e2e3ee4c9198bde831a36b64dc11
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 2 Mar 2026 17:05:02 +0100
Add data loading to sgas-lint utility
Now, the utility can already be used to check that data loading does not
return an error.
Diffstat:
1 file changed, 42 insertions(+), 0 deletions(-)
diff --git a/src/sgas_lint.c b/src/sgas_lint.c
@@ -32,6 +32,13 @@ struct args {
#define ARGS_DEFAULT__ {0}
static const struct args ARGS_DEFAULT = ARGS_DEFAULT__;
+struct cmd {
+ struct args args;
+ struct sgas* gas;
+};
+#define CMD_NULL__ {0}
+static const struct cmd CMD_NULL = CMD_NULL__;
+
/*******************************************************************************
* Helper functions
******************************************************************************/
@@ -82,6 +89,36 @@ error:
goto exit;
}
+static void
+cmd_release(struct cmd* cmd)
+{
+ ASSERT(cmd);
+ if(cmd->gas) SGAS(ref_put(cmd->gas));
+}
+
+static res_T
+cmd_init(struct cmd* cmd, const struct args* args)
+{
+ struct sgas_create_args gas_args = SGAS_CREATE_ARGS_DEFAULT;
+ res_T res = RES_OK;
+ ASSERT(cmd && args);
+
+ cmd->args = *args;
+
+ gas_args.mesh = args->mesh;
+ gas_args.therm_props_list = args->therm_props_list;
+ gas_args.verbose = args->verbose;
+
+ if((res = sgas_create(&gas_args, &cmd->gas)) != RES_OK) goto error;
+
+exit:
+ return res;
+error:
+ cmd_release(cmd);
+ *cmd = CMD_NULL;
+ goto exit;
+}
+
/*******************************************************************************
* The program
******************************************************************************/
@@ -89,12 +126,17 @@ int
main(int argc, char** argv)
{
struct args args = ARGS_DEFAULT;
+ struct cmd cmd = CMD_NULL;
int err = 0;
res_T res = RES_OK;
if((res = args_init(&args, argc, argv)) != RES_OK) goto error;
+ if(args.quit) goto exit;
+
+ if((res = cmd_init(&cmd, &args)) != RES_OK) goto error;
exit:
+ cmd_release(&cmd);
CHK(mem_allocated_size() == 0);
return err;
error: