Mercurial > hg > dmlib
comparison src/dmres.c @ 1016:b1d22289af24
Comments.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 01 Mar 2015 04:46:41 +0200 |
parents | 5101766dd95c |
children | 6436d80ae0fc |
comparison
equal
deleted
inserted
replaced
1015:5101766dd95c | 1016:b1d22289af24 |
---|---|
393 { | 393 { |
394 DMZLibContext ctx; | 394 DMZLibContext ctx; |
395 Uint8 *inBuf = NULL; | 395 Uint8 *inBuf = NULL; |
396 int ret; | 396 int ret; |
397 | 397 |
398 // Allocate buuffer for compressed data | |
398 if ((inBuf = dmMalloc(node->length)) == NULL) | 399 if ((inBuf = dmMalloc(node->length)) == NULL) |
399 { | 400 { |
400 ret = DMERR_MALLOC; | 401 ret = DMERR_MALLOC; |
401 goto out; | 402 goto out; |
402 } | 403 } |
403 | 404 |
405 // Read compressed data | |
404 if (fread(inBuf, sizeof(Uint8), node->length, handle->lib->packFile->file) != node->length) | 406 if (fread(inBuf, sizeof(Uint8), node->length, handle->lib->packFile->file) != node->length) |
405 { | 407 { |
406 ret = DMERR_FREAD; | 408 ret = DMERR_FREAD; |
407 goto out; | 409 goto out; |
408 } | 410 } |
412 ret = dmError(DMERR_MALLOC, | 414 ret = dmError(DMERR_MALLOC, |
413 "Failed to allocate initial decompression buffer.\n"); | 415 "Failed to allocate initial decompression buffer.\n"); |
414 goto out; | 416 goto out; |
415 } | 417 } |
416 | 418 |
419 // Initialize decompression structures | |
417 ctx.zbuffer = inBuf; | 420 ctx.zbuffer = inBuf; |
418 ctx.zbufferEnd = inBuf + node->length; | 421 ctx.zbufferEnd = inBuf + node->length; |
419 ctx.zoutEnd = ctx.zoutStart + node->size; | 422 ctx.zoutEnd = ctx.zoutStart + node->size; |
420 ctx.expandable = TRUE; | 423 ctx.expandable = TRUE; |
421 | 424 |