# HG changeset patch # User Matti Hamalainen # Date 1583852470 -7200 # Node ID ec8fe89576ff6a4411bea7aaa644e243f4f545bd # Parent 3707a823aa02517af2e2d3388e979182d7ebb656 Adjust th_ioctx API. Breakage. diff -r 3707a823aa02 -r ec8fe89576ff th_ioctx.c --- a/th_ioctx.c Tue Mar 10 16:51:55 2020 +0200 +++ b/th_ioctx.c Tue Mar 10 17:01:10 2020 +0200 @@ -32,7 +32,7 @@ } -th_ioctx * th_io_new(const th_ioctx_ops *fops, const char *filename) +th_ioctx * th_io_new(const th_ioctx_ops *fops, const char *filename, const char *mode) { th_ioctx *ctx = th_malloc(sizeof(th_ioctx)); if (ctx == NULL) @@ -48,6 +48,11 @@ if (filename != NULL && ctx->filename == NULL) goto err; + if (mode != NULL && (ctx->mode = th_strdup(mode)) == NULL) + goto err; + + ctx->mallocated = TRUE; + return ctx; err: @@ -56,31 +61,15 @@ } -int th_io_open(th_ioctx *ctx, const char *mode) -{ - if (ctx == NULL) - return THERR_NULLPTR; - - if (mode != NULL && (ctx->mode = th_strdup(mode)) == NULL) - return THERR_MALLOC; - - ctx->mallocated = TRUE; - - ctx->status = thfopen(ctx); - - return ctx->status; -} - - int th_io_fopen(th_ioctx **pctx, const th_ioctx_ops *fops, const char *filename, const char *mode) { th_ioctx *ctx; int res; - if ((*pctx = ctx = th_io_new(fops, filename)) == NULL) + if ((*pctx = ctx = th_io_new(fops, filename, mode)) == NULL) return THERR_MALLOC; - if ((res = th_io_open(ctx, mode)) != THERR_OK) + if ((res = thfopen(ctx)) != THERR_OK) goto err; return THERR_OK; diff -r 3707a823aa02 -r ec8fe89576ff th_ioctx.h --- a/th_ioctx.h Tue Mar 10 16:51:55 2020 +0200 +++ b/th_ioctx.h Tue Mar 10 17:01:10 2020 +0200 @@ -95,8 +95,7 @@ // // I/O context management functions // -th_ioctx * th_io_new(const th_ioctx_ops *fops, const char *filename); -int th_io_open(th_ioctx *ctx, const char *mode); +th_ioctx * th_io_new(const th_ioctx_ops *fops, const char *filename, const char *mode); int th_io_fopen(th_ioctx **pctx, const th_ioctx_ops *fops, const char *filename, const char *mode); int th_io_reopen(th_ioctx *ctx, const char *mode); void th_io_close(th_ioctx *ctx);