• 大小: 2.19MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-27
  • 语言: 其他
  • 标签: 二维码  

资源简介

这两天做二维码,发现libdecodeqr里面有内存泄露,在这里修改了下。

资源截图

代码片段和文件信息

/////////////////////////////////////////////////////////////////////////
//
// bitstream.cpp --a part of libdecodeqr
//
// Copyright(C) 2007 NISHI Takao 
//                   JMA  (Japan Medical Association)
//                   NaCl (Network Applied Communication Laboratory Ltd.)
//
// This is free software with ABSOLUTELY NO WARRANTY.
// You can redistribute and/or modify it under the terms of LGPL.
//
// $Id: bitstream.cpp 36 2007-02-21 23:22:03Z zophos $
//
#include “bitstream.h“

namespace Qr{
    BitStream::BitStream()
    {
        this->data=NULL;
        this->byte_size=0;
        this->bit_size=0;
        this->_pos=0;
    }
    BitStream::BitStream(void *srcint size)
    {
        this->byte_size=size;
        this->bit_size=size<<3;
        this->data=new unsigned char[size];
        memcpy(this->datasrcsize);
        this->_pos=0;
    }
    BitStream::~BitStream()
    {
        if(this->data)
            delete this->data;
    }

    bool BitStream::is_eod()
    {
        return(this->_pos>=this->bit_size);
    }
    int BitStream::position()
    {
        return(this->_pos);
    }
    int BitStream::seek(int pos)
    {
        this->_pos+=pos;
        if(this->_pos<0)
            this->_pos=0;
        if(this->_pos>this->bit_size)
            this->_pos=this->bit_size;
        
        return(this->_pos);
    }
    void BitStream::rewind()
    {
        this->_pos=0;
    }

    unsigned char *BitStream::read(int read_bits)
    {
        int byte_size=(read_bits>>3)+(read_bits&0x07?1:0);
        unsigned char *buf=new unsigned char[byte_size];
        memset(buf0byte_size);

        this->read(bufbyte_sizeread_bits);

        return(buf);
    }
    int BitStream::read(void *dstint buf_sizeint read_bits)
    {
        memset(dst0buf_size);

        if(read_bits>(buf_size<<3))
            read_bits=buf_size<<3;

        int end_bit=this->_pos+read_bits-1;
        if(end_bit>=this->bit_size){
            end_bit=this->bit_size-1;
            read_bits=this->bit_size-this->_pos;
        }
        int remain_bits=(end_bit+1)&0x07;
        int offset=this->_pos>>3;
        int read_bytes=(read_bits>>3)+(read_bits&0x07?1:0);

        if(read_bytes            int diff=buf_size-read_bytes;
            unsigned char *tmp=(unsigned char *)dst;
            tmp+=diff;
            dst=tmp;
        }

        if(remain_bits){
            unsigned char *src=data+offset;
            unsigned char *tmp=(unsigned char *)dst;

            int i=0;
            if(read_bytes==(end_bit>>3)-offset+1){
                tmp++;
                i++;
            }
            for(;i                *tmp=*src<            }
            remain_bits=8-remain_bits;
            src=data+(end_bit>>3);
            tmp--;
            for(i=0;i                *tmp|=*src>>remain_bits;
            }
        }
        else{
            memcpy(dstthis->data+off

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      11162  2007-02-28 08:01  libdecodeqr-0.9.3\doc\ApiReference.ja

     文件       4691  2007-02-28 08:01  libdecodeqr-0.9.3\doc\HackingGuide.ja

     文件      26436  2007-02-22 07:22  libdecodeqr-0.9.3\doc\LGPL

     文件       2418  2007-02-28 08:01  libdecodeqr-0.9.3\doc\README

     文件      23484  2006-10-09 15:57  libdecodeqr-0.9.3\img\01-1.jpg

     文件      19601  2006-10-09 15:57  libdecodeqr-0.9.3\img\01-2.jpg

     文件     126151  2006-10-09 15:57  libdecodeqr-0.9.3\img\01-3.jpg

     文件     112411  2006-10-09 15:57  libdecodeqr-0.9.3\img\01-4.jpg

     文件      15711  2006-10-09 15:57  libdecodeqr-0.9.3\img\02-1.jpg

     文件      19652  2006-10-09 15:57  libdecodeqr-0.9.3\img\02-2.jpg

     文件     101669  2006-10-09 15:57  libdecodeqr-0.9.3\img\02-3.jpg

     文件      87936  2006-10-09 15:57  libdecodeqr-0.9.3\img\02-4.jpg

     文件      16887  2006-10-09 15:57  libdecodeqr-0.9.3\img\03-1.jpg

     文件      16601  2006-10-09 15:57  libdecodeqr-0.9.3\img\03-2.jpg

     文件      99917  2006-10-09 15:57  libdecodeqr-0.9.3\img\03-3.jpg

     文件      98049  2006-10-09 15:57  libdecodeqr-0.9.3\img\03-4.jpg

     文件      24455  2006-10-09 15:57  libdecodeqr-0.9.3\img\04-1.jpg

     文件      23674  2006-10-09 15:57  libdecodeqr-0.9.3\img\04-2.jpg

     文件     120839  2006-10-09 15:57  libdecodeqr-0.9.3\img\04-3.jpg

     文件     109542  2006-10-09 15:57  libdecodeqr-0.9.3\img\04-4.jpg

     文件      20848  2006-10-09 15:57  libdecodeqr-0.9.3\img\05-1.jpg

     文件      18817  2006-10-09 15:57  libdecodeqr-0.9.3\img\05-2.jpg

     文件     133870  2006-10-09 15:57  libdecodeqr-0.9.3\img\05-3.jpg

     文件     128223  2006-10-09 15:57  libdecodeqr-0.9.3\img\05-4.jpg

     文件      21055  2006-10-09 15:57  libdecodeqr-0.9.3\img\06-1.jpg

     文件      20833  2006-10-09 15:57  libdecodeqr-0.9.3\img\06-2.jpg

     文件     120508  2006-10-09 15:57  libdecodeqr-0.9.3\img\06-3.jpg

     文件     114543  2006-10-09 15:57  libdecodeqr-0.9.3\img\06-4.jpg

     文件     230456  2006-10-09 15:57  libdecodeqr-0.9.3\img\125.bmp

     文件      65766  2009-02-18 15:45  libdecodeqr-0.9.3\img\myinfo.bmp

............此处省略77个文件信息

评论

共有 条评论