2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: CleanUp.c /main/10 1996/01/29 12:19:40 cde-hp $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 ** Project: Cde DtHelp
33 ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
35 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
36 ** (c) Copyright 1993, 1994 International Business Machines Corp.
37 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
38 ** (c) Copyright 1993, 1994 Novell, Inc.
41 ****************************************************************************
42 ************************************<+>*************************************/
50 * Canvas Engine includes
53 #include "CanvasSegP.h"
61 #include "FontAttrI.h"
62 #include "FormatUtilI.h"
64 #include "XInterfaceI.h"
69 /******** Private Function Declarations ********/
70 /******** End Private Function Declarations ********/
72 /*****************************************************************************
74 *****************************************************************************/
75 /*****************************************************************************
77 *****************************************************************************/
78 #define AbbrevStr(x) (FrmtPrivInfoPtr(x)->abbrev)
79 #define DupFlag(x) (FrmtPrivInfoPtr(x)->dup_flag)
80 #define MatchInfo(x) (FrmtPrivInfoPtr(x)->match_info)
81 #define TopFlag(x) (FrmtPrivInfoPtr(x)->top_block)
82 /*****************************************************************************
84 *****************************************************************************/
86 CheckFreePrivInfo(_DtCvSegment *seg)
89 * free the match information
91 if (NULL != MatchInfo(seg))
93 SdlMatchData *m = (SdlMatchData *)(MatchInfo(seg));
101 * free any abbreviation
103 if (NULL != AbbrevStr(seg))
104 free(AbbrevStr(seg));
108 FreePrivateAndSeg(_DtCvSegment *seg)
113 * free the private information block
115 if (NULL != FrmtPrivInfoPtr(seg))
116 free(FrmtPrivInfoPtr(seg));
119 * free the segment block
125 /*****************************************************************************
126 * Semi-Private Variables
127 *****************************************************************************/
128 /*****************************************************************************
129 * Semi-Public Functions
130 *****************************************************************************/
131 /*****************************************************************************
132 * Function: void _DtHelpFreeSegments (_DtCvSegment *seg_list)
135 * seg_list Specifies the Canvas Engine segment list.
139 * Purpose: Free all memory associated with an SDL list.
140 *****************************************************************************/
142 _DtHelpFreeSegments (
143 _DtCvSegment *seg_list,
144 _DtCvStatus unresolved,
145 void (*destroy_region)(),
146 _DtCvPointer client_data)
151 _DtCvSegment *nextSeg;
152 _DtCvSegment *topSeg = NULL;
153 _DtCvSegment *topTab = NULL;
154 _DtCvSegment **tableSeg;
155 _DtHelpDARegion *pReg;
157 while (seg_list != NULL)
159 dupFlag = DupFlag(seg_list);
160 nextSeg = seg_list->next_seg;
161 switch (_DtCvPrimaryTypeOfSeg(seg_list))
167 if (False == dupFlag &&
168 NULL != _DtCvContainerIdOfSeg(seg_list))
169 free(_DtCvContainerIdOfSeg(seg_list));
172 * free the contents of the block
174 _DtHelpFreeSegments(_DtCvContainerListOfSeg(seg_list),
181 if (False == dupFlag)
182 free(_DtCvIdOfMarkerSeg(seg_list));
186 if (False == dupFlag && NULL != destroy_region)
187 (destroy_region)(client_data,
188 _DtCvInfoOfRegionSeg(seg_list));
192 if (False == dupFlag)
194 free(_DtCvStringOfStringSeg(seg_list));
195 if (True == unresolved &&
196 NULL != _DtCvFontOfStringSeg(seg_list))
197 free(_DtCvFontOfStringSeg(seg_list));
208 tableSeg = _DtCvCellsOfTableSeg(seg_list);
209 while (NULL != tableSeg && NULL != *tableSeg)
214 if (False == DupFlag(*tableSeg)
215 && NULL != _DtCvContainerIdOfSeg(*tableSeg))
216 free(_DtCvContainerIdOfSeg(*tableSeg));
219 * free the contents of the block
222 _DtCvContainerListOfSeg(*tableSeg),
230 * free each of the table cells
232 tableSeg = _DtCvCellsOfTableSeg(seg_list);
233 while (NULL != tableSeg && NULL != *tableSeg)
235 if (True == TopFlag(*tableSeg))
237 FreePrivateAndSeg(topTab);
240 CheckFreePrivInfo(*tableSeg);
244 FreePrivateAndSeg(topTab);
248 * free the list of cells
250 tableSeg = _DtCvCellsOfTableSeg(seg_list);
256 _DtHelpCeFreeStringArray(
257 _DtCvCellIdsOfTableSeg(seg_list));
260 * free the column justification and width.
262 free((void *) _DtCvColJustifyOfTableSeg(seg_list));
263 strs = _DtCvColWOfTableSeg(seg_list);
265 NULL != strs && i < _DtCvNumColsOfTableSeg(seg_list);
267 free((void *) *strs);
268 if (NULL != _DtCvColWOfTableSeg(seg_list))
269 free((void *) _DtCvColWOfTableSeg(seg_list));
274 CheckFreePrivInfo(seg_list);
275 if (True == TopFlag(seg_list))
277 FreePrivateAndSeg(topSeg);
283 FreePrivateAndSeg(topSeg);
285 } /* End _DtHelpFreeSegments */
287 /*****************************************************************************
288 * Function: void _DtHelpDestroyTopicData (
289 * _DtCvSegment *seg_list)
292 * seg_list Specifies the SDL segment list.
296 * Purpose: Free all memory associated with an SDL list.
297 *****************************************************************************/
299 _DtHelpDestroyTopicData (
300 _DtCvTopicInfo *topic,
301 void (*destroy_region)(),
302 _DtCvPointer client_data)
307 * free the segment list
309 _DtHelpFreeSegments(topic->seg_list, _DtCvFALSE,
310 destroy_region, client_data);
315 if (NULL != topic->id_str)
321 _DtLinkDbDestroy(topic->link_data);
329 } /* End _DtHelpDestroyTopicData */