Menu

LzmaEncode: Reasonable dest buffer size

Help
Fred
2013-08-10
2013-08-10
  • Fred

    Fred - 2013-08-10

    Hi,
    what destination buffer size should I use for LzmaEncode?
    I found on the web
    destLen = srcLen + srcLen/3 + 128;
    This is far too large and wasting memory, if I can rely on my tests encoding random data.

    For props.dictSize I choose a value near the source data length, is this a good choice?

    TIA,
    Fred

    @Igor: Thank you for providing the LZMA code.

     
  • Igor Pavlov

    Igor Pavlov - 2013-08-10

    In most cases
    srcLen + srcLen/40 + (1 << 12)
    is OK.

    But if some "BAD_data" attack is possible, you must support
    bigger buffer. I suppose that
    srcLen + srcLen/5 + (1 << 16).
    is OK for any data.

     
  • Fred

    Fred - 2013-08-10

    Thank you for your quick reply!
    Regards,
    Fred

     

Log in to post a comment.