comparison src/dmres.c @ 1121:043b5942fdb6

Rename some dmzlib functions and add context init/close functions.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 04 Mar 2015 04:37:58 +0200
parents f8e9f6b2a41a
children 320dcfd1bd75
comparison
equal deleted inserted replaced
1120:c1583a2278ec 1121:043b5942fdb6
408 ret = DMERR_FREAD; 408 ret = DMERR_FREAD;
409 goto out; 409 goto out;
410 } 410 }
411 411
412 // Initialize decompression structures 412 // Initialize decompression structures
413 if ((ret = dmZLibInitInflate(&ctx)) != DMERR_OK)
414 goto out;
413 ctx.inBuffer = ctx.inBufferStart = inBuf; 415 ctx.inBuffer = ctx.inBufferStart = inBuf;
414 ctx.inBufferEnd = inBuf + node->length; 416 ctx.inBufferEnd = inBuf + node->length;
415
416 ctx.outBuffer = ctx.outBufferStart = handle->rawData; 417 ctx.outBuffer = ctx.outBufferStart = handle->rawData;
417 ctx.outBufferEnd = handle->rawData + node->size; 418 ctx.outBufferEnd = handle->rawData + node->size;
418 ctx.expandable = FALSE; 419 ctx.expandable = FALSE;
419 420
420 // Attempt decompression 421 // Attempt decompression
421 if ((ret = dmZLibParseHeader(&ctx, TRUE)) != DMERR_OK) 422 if ((ret = dmZLibParseHeader(&ctx, TRUE)) != DMERR_OK)
422 goto out; 423 goto out;
423 424
424 if ((ret = dmZLibDecode(&ctx)) != DMERR_OK) 425 if ((ret = dmZLibInflate(&ctx)) != DMERR_OK)
425 goto out; 426 goto out;
426 427
427 handle->rawData = ctx.outBufferStart; 428 handle->rawData = ctx.outBufferStart;
428 handle->rawSize = ctx.outBuffer - ctx.outBufferStart; 429 handle->rawSize = ctx.outBuffer - ctx.outBufferStart;
429 430
430 out: 431 out:
432 dmZLibCloseInflate(&ctx);
431 dmFree(inBuf); 433 dmFree(inBuf);
432 return ret; 434 return ret;
433 } 435 }
434 436
435 #endif 437 #endif