Mercurial > hg > th-libs
comparison th_ioctx.c @ 769:8eca15bde07d
Rename some th_ioctx members.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 12 Feb 2023 09:04:33 +0200 |
parents | 31bc1ed07cf5 |
children | c17eadc60c3d |
comparison
equal
deleted
inserted
replaced
768:600a3c08747f | 769:8eca15bde07d |
---|---|
38 if (ctx == NULL) | 38 if (ctx == NULL) |
39 return NULL; | 39 return NULL; |
40 | 40 |
41 th_io_init(ctx); | 41 th_io_init(ctx); |
42 | 42 |
43 ctx->allocated = true; | 43 ctx->ctx_allocated = true; |
44 ctx->fops = fops; | 44 ctx->fops = fops; |
45 | 45 |
46 ctx->filename = th_strdup(filename); | 46 ctx->filename = th_strdup(filename); |
47 ctx->fallocated = true; | 47 ctx->fn_allocated = true; |
48 if (filename != NULL && ctx->filename == NULL) | 48 if (filename != NULL && ctx->filename == NULL) |
49 goto err; | 49 goto err; |
50 | 50 |
51 if (mode != NULL && (ctx->mode = th_strdup(mode)) == NULL) | 51 if (mode != NULL && (ctx->mode = th_strdup(mode)) == NULL) |
52 goto err; | 52 goto err; |
53 | 53 |
54 ctx->mallocated = true; | 54 ctx->md_allocated = true; |
55 | 55 |
56 return ctx; | 56 return ctx; |
57 | 57 |
58 err: | 58 err: |
59 th_io_close(ctx); | 59 th_io_close(ctx); |
86 if (ctx == NULL) | 86 if (ctx == NULL) |
87 return THERR_NULLPTR; | 87 return THERR_NULLPTR; |
88 | 88 |
89 thfclose(ctx); | 89 thfclose(ctx); |
90 | 90 |
91 if (ctx->mallocated) | 91 if (ctx->md_allocated) |
92 { | 92 { |
93 if ((ctx->status = th_pstr_cpy(&ctx->mode, mode)) != THERR_OK) | 93 if ((ctx->status = th_pstr_cpy(&ctx->mode, mode)) != THERR_OK) |
94 return ctx->status; | 94 return ctx->status; |
95 } | 95 } |
96 else | 96 else |
97 { | 97 { |
98 ctx->mallocated = true; | 98 ctx->md_allocated = true; |
99 if ((ctx->mode = th_strdup(mode)) == NULL) | 99 if ((ctx->mode = th_strdup(mode)) == NULL) |
100 return THERR_MALLOC; | 100 return THERR_MALLOC; |
101 } | 101 } |
102 | 102 |
103 return (ctx->status = thfopen(ctx)); | 103 return (ctx->status = thfopen(ctx)); |
108 { | 108 { |
109 if (ctx != NULL) | 109 if (ctx != NULL) |
110 { | 110 { |
111 thfclose(ctx); | 111 thfclose(ctx); |
112 | 112 |
113 if (ctx->fallocated) | 113 if (ctx->fn_allocated) |
114 th_free_r(&ctx->filename); | 114 th_free_r(&ctx->filename); |
115 | 115 |
116 if (ctx->mallocated) | 116 if (ctx->md_allocated) |
117 th_free_r(&ctx->mode); | 117 th_free_r(&ctx->mode); |
118 | 118 |
119 if (ctx->allocated) | 119 if (ctx->ctx_allocated) |
120 th_free(ctx); | 120 th_free(ctx); |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 | 124 |