Mercurial > hg > th-libs
changeset 209:462b837ea492
Change io context API. Again.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 12 Feb 2016 03:00:19 +0200 |
parents | 3635415a2d03 |
children | 2341776f880b |
files | th_ioctx.c th_ioctx.h |
diffstat | 2 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/th_ioctx.c Fri Feb 12 02:49:21 2016 +0200 +++ b/th_ioctx.c Fri Feb 12 03:00:19 2016 +0200 @@ -11,24 +11,24 @@ #include <stdio.h> -th_ioctx *th_io_new(const th_ioctx_ops *fops) +th_ioctx *th_io_new(const th_ioctx_ops *fops, const char *filename) { th_ioctx *ctx = th_malloc0(sizeof(th_ioctx)); if (ctx == NULL) return NULL; ctx->fops = fops; + ctx->filename = th_strdup(filename); return ctx; } -int th_io_open(th_ioctx *ctx, const char *filename, const char *mode) +int th_io_open(th_ioctx *ctx, const char *mode) { if (ctx == NULL) return THERR_NULLPTR; - ctx->filename = th_strdup(filename); ctx->mode = th_strdup(mode); if (ctx->fops->fopen != NULL) @@ -40,11 +40,11 @@ th_ioctx * th_io_fopen(const th_ioctx_ops *fops, const char *filename, const char *mode) { - th_ioctx *ctx = th_io_new(fops); + th_ioctx *ctx = th_io_new(fops, filename); if (ctx == NULL) return NULL; - if (th_io_open(ctx, filename, mode) != THERR_OK) + if (th_io_open(ctx, mode) != THERR_OK) { th_io_free(ctx); return NULL;
--- a/th_ioctx.h Fri Feb 12 02:49:21 2016 +0200 +++ b/th_ioctx.h Fri Feb 12 03:00:19 2016 +0200 @@ -75,8 +75,8 @@ // // I/O context management functions // -th_ioctx * th_io_new(const th_ioctx_ops *fops); -int th_io_open(th_ioctx *ctx, const char *filename, const char *mode); +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_fopen(const th_ioctx_ops *fops, const char *filename, const char *mode); void th_io_close(th_ioctx *ctx); void th_io_free(th_ioctx *ctx);