summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/driver/sfrt_unit_ctx.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/driver/sfrt_unit_ctx.c b/src/driver/sfrt_unit_ctx.c
index a17d78d..0052cce 100644
--- a/src/driver/sfrt_unit_ctx.c
+++ b/src/driver/sfrt_unit_ctx.c
@@ -6,15 +6,16 @@
#include <sofort/sofort.h>
#include "sofort_driver_impl.h"
+#include "sofort_errinfo_impl.h"
-static int sfrt_free_unit_ctx_impl(struct sfrt_unit_ctx_impl * ctx, int status)
+static int sfrt_free_unit_ctx_impl(struct sfrt_unit_ctx_impl * ctx, int ret)
{
if (ctx) {
sfrt_unmap_input(&ctx->map);
free(ctx);
}
- return status;
+ return ret;
}
int sfrt_get_unit_ctx(
@@ -24,11 +25,19 @@ int sfrt_get_unit_ctx(
{
struct sfrt_unit_ctx_impl * ctx;
- if (!dctx || !(ctx = calloc(1,sizeof(*ctx))))
- return -1;
+ if (!dctx)
+ return SFRT_CUSTOM_ERROR(
+ dctx,SFRT_ERR_NULL_CONTEXT);
+
+ else if (!(ctx = calloc(1,sizeof(*ctx))))
+ return SFRT_BUFFER_ERROR(dctx);
+
+ sfrt_driver_set_ectx(
+ dctx,0,path);
if (sfrt_map_input(dctx,-1,path,PROT_READ,&ctx->map))
- return sfrt_free_unit_ctx_impl(ctx,-1);
+ return sfrt_free_unit_ctx_impl(ctx,
+ SFRT_NESTED_ERROR(dctx));
memcpy(&ctx->cctx,dctx->cctx,
sizeof(ctx->cctx));