Phase 1 plus some refactoring.

This commit is contained in:
Johannes Findeisen 2026-10-26 23:20:00 +01:00
commit 8075e1b79d
17 changed files with 465 additions and 266 deletions

View file

@ -2,45 +2,45 @@
#include <stdlib.h>
struct xt_app {
struct xtc_app {
unsigned int reserved;
};
const char *xt_result_string(xt_result result)
const char *xtc_result_string(xtc_result result)
{
switch (result) {
case XT_OK: return "success";
case XT_ERR_INVALID_ARGUMENT: return "invalid argument";
case XT_ERR_OUT_OF_MEMORY: return "out of memory";
case XT_ERR_NOT_FOUND: return "not found";
case XT_ERR_INVALID_STATE: return "invalid state";
case XT_ERR_IO: return "I/O error";
case XT_ERR_UNSUPPORTED: return "unsupported operation";
case XT_ERR_CAPACITY: return "capacity exceeded";
case XT_ERR_GRAPH_CYCLE: return "graph contains a cycle";
case XTC_OK: return "success";
case XTC_ERR_INVALID_ARGUMENT: return "invalid argument";
case XTC_ERR_OUT_OF_MEMORY: return "out of memory";
case XTC_ERR_NOT_FOUND: return "not found";
case XTC_ERR_INVALID_STATE: return "invalid state";
case XTC_ERR_IO: return "I/O error";
case XTC_ERR_UNSUPPORTED: return "unsupported operation";
case XTC_ERR_CAPACITY: return "capacity exceeded";
case XTC_ERR_GRAPH_CYCLE: return "graph contains a cycle";
default: return "unknown error";
}
}
xt_result xt_app_create(xt_app **out_app)
xtc_result xtc_app_create(xtc_app **out_app)
{
xt_app *app;
xtc_app *app;
if (out_app == NULL) {
return XT_ERR_INVALID_ARGUMENT;
return XTC_ERR_INVALID_ARGUMENT;
}
*out_app = NULL;
app = (xt_app *)calloc(1U, sizeof(*app));
app = (xtc_app *)calloc(1U, sizeof(*app));
if (app == NULL) {
return XT_ERR_OUT_OF_MEMORY;
return XTC_ERR_OUT_OF_MEMORY;
}
*out_app = app;
return XT_OK;
return XTC_OK;
}
void xt_app_destroy(xt_app *app)
void xtc_app_destroy(xtc_app *app)
{
free(app);
}