Menu

#337 modify comment in the LzmaLib.h

open
None
5
2019-06-27
2019-06-27
Bruce Stark
No

I encountered an error when I used the LzmaCompress API:
1. Did not assign the initial value to the variable destLen;
2. the return value of LzmaCompress was SZ_ERROR_OUTPUT_EOF;

{
...
size_t destLen;
My_STDAPI Res = LzmaCompress(dest,&destLen,src,srcLen,outProps,&outPropsSize,
                0,1<<16,3,0,2,32,2);
...
}

But, I found the source code is that:

{
    ...
    LzmaCompress(...)
    {
        Lzmacode(...)
        {
            ...
            LzmaEnc_MemEncode(...)
            {
                ...
                outStream.rem = *destLen;
                ...
            }
            ...
        }
    }
...
}

SO,I think the destLen is not only an output value, but also an input value.

Discussion

  • Igor Pavlov

    Igor Pavlov - 2019-06-27

    Yes, it's obvious.
    If you provide the output buffer, some function's parameter contains the size of that buffer.
    I'll add comment in h file about.
    Thanks!

     
  • Bruce Stark

    Bruce Stark - 2019-06-27

    However, the LzmaLib.h file shows that the destLen is just an output value.

    /*
    ...
    Out:
        destLen - processed output size
    Return:
        SZ_OK   - OK
     ...
    */
    

    In order to solve the error above, I give destLen an initial value and test it again. The result is OK.
    {
    ...
    size_t destLen = srcLen;
    My_STDAPI Res = LzmaCompress(dest,&destLen,src,srcLen,outProps,&outPropsSize,
    0,1<<16,3,0,2,32,2);
    ...
    }

    So, I suggest to modify the comment in the LzmaLib.h file , and the destLen have to give an initial value.

    /*
    ...
    In/Out:
        destLen - processed output size
    Return:
        SZ_OK   - OK
     ...
    */
    
     

    Last edit: Bruce Stark 2019-06-27
  • Igor Pavlov

    Igor Pavlov - 2019-06-27

    Look LzmaUncompress description.
    It has similar parameters.

     
  • Bruce Stark

    Bruce Stark - 2019-06-27

    Yes, that's right.
    I have modified it according the LzmaUncompress description

     

    Last edit: Bruce Stark 2019-06-27

Log in to post a comment.