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