help needed to understanding the c code of lzma

  • Sanjayan Ravi

    Sanjayan Ravi - 2013-12-17


    I am trying to learn and understand the C code of lzma which is available from the LZMA SDK in 7zip website. I am not an expert in C programming so I am having a hard time understanding some functions.

    One such function is the “LzmaEnc_Create” from the file LzmaEnc.c in the c code folder of lzma [line number 1700][].

    I have copied the code of LzmaEnc_Create below.

    CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc)


    void *p;

    printf("size of encode = %d\n",sizeof(CLzmaEnc));

    p = alloc->Alloc(alloc, sizeof(CLzmaEnc));

    if (p != 0)

    LzmaEnc_Construct((CLzmaEnc *)p);

    return p;


    I would really appreciate any help provided to help me learn and understand this program.

    Thank you!

  • Igor Pavlov

    Igor Pavlov - 2013-12-17

    Ask your question and don't attach any files.

  • Shell

    Shell - 2013-12-17

    Sanjayan Ravi: the above function allocates memory for LZMA encoder. Some programmers inline such functions entirely: this may reduce (negligibly) binary code size and its execution time. Creating a separate function improves source code readability and manageability. Is this an answer to your question?

  • Sanjayan Ravi

    Sanjayan Ravi - 2013-12-18

    Igor Pavlov: I am sorry.

  • Sanjayan Ravi

    Sanjayan Ravi - 2013-12-18

    Dear Mr.Shell,

    Thank you so much for your reply, this answers my question.


Log in to post a comment.