Mercurial > hg > dmlib
changeset 2445:fa089a430121
Cleanup, rename DMResource::error to DMResource::status.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 09 Mar 2020 22:37:00 +0200 |
parents | fd31b5d1ed5e |
children | 8193f62a541d |
files | src/dmres.c src/dmres.h |
diffstat | 2 files changed, 27 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dmres.c Mon Mar 09 22:29:29 2020 +0200 +++ b/src/dmres.c Mon Mar 09 22:37:00 2020 +0200 @@ -182,7 +182,7 @@ handle->fh = fopen(rfilename, "rb"); dmFree(rfilename); - handle->error = dmGetErrno(); + handle->status = dmGetErrno(); return (handle->fh != NULL) ? DMERR_OK : DMERR_FOPEN; } @@ -199,7 +199,7 @@ static int dm_stdio_ferror(DMResource *fh) { - return fh->error; + return fh->status; } @@ -212,7 +212,7 @@ static int dm_stdio_fseek(DMResource *fh, const off_t pos, const int whence) { int ret = fseeko(fh->fh, pos, whence); - fh->error = dmGetErrno(); + fh->status = dmGetErrno(); return ret; } @@ -261,7 +261,7 @@ static int dm_stdio_fgetc(DMResource *fh) { int ret = fgetc(fh->fh); - fh->error = dmGetErrno(); + fh->status = dmGetErrno(); return ret; } @@ -269,7 +269,7 @@ static int dm_stdio_fputc(int v, DMResource *fh) { int ret = fputc(v, fh->fh); - fh->error = dmGetErrno(); + fh->status = dmGetErrno(); return ret; } @@ -277,7 +277,7 @@ static size_t dm_stdio_fread(void *ptr, size_t size, size_t nmemb, DMResource *fh) { size_t ret = fread(ptr, size, nmemb, fh->fh); - fh->error = dmGetErrno(); + fh->status = dmGetErrno(); return ret; } @@ -285,7 +285,7 @@ static size_t dm_stdio_fwrite(const void *ptr, size_t size, size_t nmemb, DMResource *fh) { size_t ret = fwrite(ptr, size, nmemb, fh->fh); - fh->error = dmGetErrno(); + fh->status = dmGetErrno(); return ret; } @@ -424,7 +424,7 @@ static int dm_pack_decompress(DMResource *handle, DMPackEntry *node) { - DMZLibContext ctx; + DMZLibContext zctx; Uint8 *inBuf = NULL; int ret; @@ -443,27 +443,27 @@ } // Initialize decompression structures - if ((ret = dmZLibInitInflate(&ctx)) != DMERR_OK) + if ((ret = dmZLibInitInflate(&zctx)) != DMERR_OK) goto out; - ctx.inBuffer = ctx.inBufferStart = inBuf; - ctx.inBufferEnd = inBuf + node->length; - ctx.outBuffer = ctx.outBufferStart = handle->memData; - ctx.outBufferEnd = handle->memData + node->size; - ctx.expandable = FALSE; + zctx.inBuffer = zctx.inBufferStart = inBuf; + zctx.inBufferEnd = inBuf + node->length; + zctx.outBuffer = zctx.outBufferStart = handle->memData; + zctx.outBufferEnd = handle->memData + node->size; + zctx.expandable = FALSE; // Attempt decompression - if ((ret = dmZLibParseHeader(&ctx, TRUE)) != DMERR_OK) + if ((ret = dmZLibParseHeader(&zctx, TRUE)) != DMERR_OK) goto out; - if ((ret = dmZLibInflate(&ctx)) != DMERR_OK) + if ((ret = dmZLibInflate(&zctx)) != DMERR_OK) goto out; - handle->memData = ctx.outBufferStart; - handle->memSize = ctx.outBuffer - ctx.outBufferStart; + handle->memData = zctx.outBufferStart; + handle->memSize = zctx.outBuffer - zctx.outBufferStart; out: - dmZLibCloseInflate(&ctx); + dmZLibCloseInflate(&zctx); dmFree(inBuf); return ret; } @@ -572,7 +572,7 @@ // Check against max size if (ctx->maxSize > 0 && newSize > ctx->maxSize) { - ctx->error = DMERR_BOUNDS; + ctx->status = DMERR_BOUNDS; return FALSE; } @@ -587,7 +587,7 @@ if (ctx->maxSize > 0 && ctx->memAlloc + grow >= ctx->maxSize) { - ctx->error = DMERR_BOUNDS; + ctx->status = DMERR_BOUNDS; return FALSE; } @@ -595,7 +595,7 @@ ctx->memAlloc += grow; if ((ctx->memData = dmRealloc(ctx->memData, ctx->memAlloc)) == NULL) { - ctx->error = DMERR_MALLOC; + ctx->status = DMERR_MALLOC; return FALSE; } @@ -615,7 +615,7 @@ static int dm_mem_ferror(DMResource *ctx) { - return ctx->error; + return ctx->status; } @@ -909,11 +909,11 @@ handle->fops = &dfStdioFileOps; handle->fh = fopen(filename, mode); - handle->error = dmGetErrno(); + handle->status = dmGetErrno(); if (handle->fh == NULL) { - int error = handle->error; + int error = handle->status; dmResourceFree(handle); return error; } @@ -1345,7 +1345,7 @@ char *str = dm_strdup_vprintf_len(fmt, ap, &len); if (str == NULL) { - fh->error = DMERR_MALLOC; + fh->status = DMERR_MALLOC; return -1; }