Exemplo n.º 1
0
            public SRes LzmaDec_Allocate(P<byte> props, uint propsSize, ISzAlloc alloc)
            {
                CLzmaProps propNew = new CLzmaProps();

                SRes res;
                if ((res = propNew.LzmaProps_Decode(props, propsSize)) != SZ_OK)
                    return res;

                if ((res = LzmaDec_AllocateProbs2(propNew, alloc)) != SZ_OK)
                    return res;

                long dicBufSize = propNew.mDicSize;
                if (mDic == null || dicBufSize != mDicBufSize)
                {
                    LzmaDec_FreeDict(alloc);
                    mDic = alloc.AllocBytes(alloc, dicBufSize);
                    if (mDic == null)
                    {
                        LzmaDec_FreeProbs(alloc);
                        return SZ_ERROR_MEM;
                    }
                }

                mDicBufSize = dicBufSize;
                mProp = new CLzmaProps(propNew);
                return SZ_OK;
            }
Exemplo n.º 2
0
            /* ---------- Interfaces ---------- */

            /* There are 3 levels of interfaces:
                 1) Dictionary Interface
                 2) Buffer Interface
                 3) One Call Interface
               You can select any of these interfaces, but don't mix functions from different
               groups for same object. */


            /* There are two variants to allocate state for Dictionary Interface:
                 1) LzmaDec_Allocate / LzmaDec_Free
                 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs
               You can use variant 2, if you set dictionary buffer manually.
               For Buffer Interface you must always use variant 1.

            LzmaDec_Allocate* can return:
              SZ_OK
              SZ_ERROR_MEM         - Memory allocation error
              SZ_ERROR_UNSUPPORTED - Unsupported properties
            */

            public SRes LzmaDec_AllocateProbs(P<byte> props, uint propsSize, ISzAlloc alloc)
            {
                SRes res;
                CLzmaProps propNew = new CLzmaProps();
                if ((res = propNew.LzmaProps_Decode(props, propsSize)) != SZ_OK) return res;
                if ((res = LzmaDec_AllocateProbs2(propNew, alloc)) != SZ_OK) return res;
                mProp = new CLzmaProps(propNew);
                return SZ_OK;
            }