Mercurial > hg > th-libs
changeset 700:ec8fe89576ff
Adjust th_ioctx API. Breakage.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 10 Mar 2020 17:01:10 +0200 |
parents | 3707a823aa02 |
children | d687bbb54c1a |
files | th_ioctx.c th_ioctx.h |
diffstat | 2 files changed, 9 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- 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;
--- 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);