# HG changeset patch # User Matti Hamalainen # Date 1583786220 -7200 # Node ID fa089a4301212c8a4c8be3b31c64db432e0cd309 # Parent fd31b5d1ed5e4b0bc860d18e08d76c53138003ff Cleanup, rename DMResource::error to DMResource::status. diff -r fd31b5d1ed5e -r fa089a430121 src/dmres.c --- 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; } diff -r fd31b5d1ed5e -r fa089a430121 src/dmres.h --- a/src/dmres.h Mon Mar 09 22:29:29 2020 +0200 +++ b/src/dmres.h Mon Mar 09 22:37:00 2020 +0200 @@ -77,7 +77,7 @@ size_t resSize; struct DMResourceDataOps *rops; - int error; // Error code + int status; // Error / status code (DMERR_*) #ifdef DM_USE_STDIO FILE * fh; // File handle for stdio