1// Copyright 2014 PDFium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7#include "JBig2_Segment.h" 8CJBig2_Segment::CJBig2_Segment() 9{ 10 init(); 11} 12CJBig2_Segment::~CJBig2_Segment() 13{ 14 clean(); 15} 16void CJBig2_Segment::init() 17{ 18 m_dwNumber = 0; 19 m_cFlags.c = 0; 20 m_nReferred_to_segment_count = 0; 21 m_pReferred_to_segment_numbers = NULL; 22 m_dwPage_association = 0; 23 m_dwData_length = 0; 24 m_dwHeader_Length = 0; 25 m_pData = NULL; 26 m_State = JBIG2_SEGMENT_HEADER_UNPARSED; 27 m_nResultType = JBIG2_VOID_POINTER; 28 m_Result.vd = NULL; 29} 30void CJBig2_Segment::clean() 31{ 32 if(m_pReferred_to_segment_numbers) { 33 m_pModule->JBig2_Free(m_pReferred_to_segment_numbers); 34 } 35 if(m_Result.vd) { 36 switch(m_nResultType) { 37 case JBIG2_IMAGE_POINTER: 38 delete m_Result.im; 39 break; 40 case JBIG2_SYMBOL_DICT_POINTER: 41 delete m_Result.sd; 42 break; 43 case JBIG2_PATTERN_DICT_POINTER: 44 delete m_Result.pd; 45 break; 46 case JBIG2_HUFFMAN_TABLE_POINTER: 47 delete m_Result.ht; 48 break; 49 default: 50 m_pModule->JBig2_Free(m_Result.vd); 51 } 52 } 53} 54