diff --git a/private/zipmat.mexa64 b/private/zipmat.mexa64 index abecfc7..7cdd79a 100755 Binary files a/private/zipmat.mexa64 and b/private/zipmat.mexa64 differ diff --git a/src/zmat.cpp b/src/zmat.cpp index 8cebb13..b8b011b 100644 --- a/src/zmat.cpp +++ b/src/zmat.cpp @@ -215,7 +215,7 @@ void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) { } catch (const std::exception& err) { mexPrintf("C++ Error: %s\n", err.what()); } catch (...) { - mexPrintf("Unknown Exception"); + mexPrintf("Unknown Exception\n"); } return; diff --git a/src/zmatlib.c b/src/zmatlib.c index 416d18b..265698d 100644 --- a/src/zmatlib.c +++ b/src/zmatlib.c @@ -190,6 +190,7 @@ int zmat_run(const size_t inputsize, unsigned char* inputstr, size_t* outputsize *outputsize = zs.total_out; if (*ret != Z_STREAM_END && *ret != Z_OK) { + deflateEnd(&zs); return -3; } @@ -268,7 +269,7 @@ int zmat_run(const size_t inputsize, unsigned char* inputstr, size_t* outputsize zs.next_out = (Bytef*)(*outputbuf); /*(Bytef *)(); // output char array*/ - while ((*ret = inflate(&zs, Z_SYNC_FLUSH)) != Z_STREAM_END && count <= 10) { + while ((*ret = inflate(&zs, Z_SYNC_FLUSH)) != Z_STREAM_END && *ret != Z_DATA_ERROR && count <= 10) { *outputbuf = (unsigned char*)realloc(*outputbuf, (buflen[0] << count)); zs.next_out = (Bytef*)(*outputbuf + (buflen[0] << (count - 1))); zs.avail_out = (buflen[0] << (count - 1)); /* size of output*/ @@ -278,6 +279,7 @@ int zmat_run(const size_t inputsize, unsigned char* inputstr, size_t* outputsize *outputsize = zs.total_out; if (*ret != Z_STREAM_END && *ret != Z_OK) { + inflateEnd(&zs); return -3; } diff --git a/zmat.m b/zmat.m index 6232612..89b8887 100644 --- a/zmat.m +++ b/zmat.m @@ -112,6 +112,10 @@ end if (exist('inputinfo', 'var') && isfield(inputinfo, 'type')) - varargout{1} = typecast(varargout{1}, inputinfo.type); + if(strcmp(inputinfo.type,'logical')) + varargout{1} = logical(varargout{1}); + else + varargout{1} = typecast(varargout{1}, inputinfo.type); + end varargout{1} = reshape(varargout{1}, inputinfo.size); end