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 ************************************<+>*************************************/
48 #include <X11/Intrinsic.h>
51 * Canvas Engine includes
54 #include "CanvasSegP.h"
62 #include "FontAttrI.h"
63 #include "FormatUtilI.h"
65 #include "StringFuncsI.h"
66 #include "XInterfaceI.h"
71 /******** Private Function Declarations ********/
72 /******** End Private Function Declarations ********/
74 /*****************************************************************************
76 *****************************************************************************/
77 /*****************************************************************************
79 *****************************************************************************/
80 #define AbbrevStr(x) (FrmtPrivInfoPtr(x)->abbrev)
81 #define DupFlag(x) (FrmtPrivInfoPtr(x)->dup_flag)
82 #define MatchInfo(x) (FrmtPrivInfoPtr(x)->match_info)
83 #define TopFlag(x) (FrmtPrivInfoPtr(x)->top_block)
84 /*****************************************************************************
86 *****************************************************************************/
88 CheckFreePrivInfo(_DtCvSegment *seg)
91 * free the match information
93 if (NULL != MatchInfo(seg))
95 SdlMatchData *m = (SdlMatchData *)(MatchInfo(seg));
103 * free any abbreviation
105 if (NULL != AbbrevStr(seg))
106 free(AbbrevStr(seg));
110 FreePrivateAndSeg(_DtCvSegment *seg)
115 * free the private information block
117 if (NULL != FrmtPrivInfoPtr(seg))
118 free(FrmtPrivInfoPtr(seg));
121 * free the segment block
127 /*****************************************************************************
128 * Semi-Private Variables
129 *****************************************************************************/
130 /*****************************************************************************
131 * Semi-Public Functions
132 *****************************************************************************/
133 /*****************************************************************************
134 * Function: void _DtHelpFreeSegments (_DtCvSegment *seg_list)
137 * seg_list Specifies the Canvas Engine segment list.
141 * Purpose: Free all memory associated with an SDL list.
142 *****************************************************************************/
144 _DtHelpFreeSegments (
145 _DtCvSegment *seg_list,
146 _DtCvStatus unresolved,
147 void (*destroy_region)(),
148 _DtCvPointer client_data)
153 _DtCvSegment *nextSeg;
154 _DtCvSegment *topSeg = NULL;
155 _DtCvSegment *topTab = NULL;
156 _DtCvSegment **tableSeg;
158 while (seg_list != NULL)
160 dupFlag = DupFlag(seg_list);
161 nextSeg = seg_list->next_seg;
162 switch (_DtCvPrimaryTypeOfSeg(seg_list))
168 if (False == dupFlag &&
169 NULL != _DtCvContainerIdOfSeg(seg_list))
170 free(_DtCvContainerIdOfSeg(seg_list));
173 * free the contents of the block
175 _DtHelpFreeSegments(_DtCvContainerListOfSeg(seg_list),
182 if (False == dupFlag)
183 free(_DtCvIdOfMarkerSeg(seg_list));
187 if (False == dupFlag && NULL != destroy_region)
188 (destroy_region)(client_data,
189 _DtCvInfoOfRegionSeg(seg_list));
193 if (False == dupFlag)
195 free(_DtCvStringOfStringSeg(seg_list));
196 if (True == unresolved &&
197 NULL != _DtCvFontOfStringSeg(seg_list))
198 free(_DtCvFontOfStringSeg(seg_list));
209 tableSeg = _DtCvCellsOfTableSeg(seg_list);
210 while (NULL != tableSeg && NULL != *tableSeg)
215 if (False == DupFlag(*tableSeg)
216 && NULL != _DtCvContainerIdOfSeg(*tableSeg))
217 free(_DtCvContainerIdOfSeg(*tableSeg));
220 * free the contents of the block
223 _DtCvContainerListOfSeg(*tableSeg),
231 * free each of the table cells
233 tableSeg = _DtCvCellsOfTableSeg(seg_list);
234 while (NULL != tableSeg && NULL != *tableSeg)
236 if (True == TopFlag(*tableSeg))
238 FreePrivateAndSeg(topTab);
241 CheckFreePrivInfo(*tableSeg);
245 FreePrivateAndSeg(topTab);
249 * free the list of cells
251 tableSeg = _DtCvCellsOfTableSeg(seg_list);
257 _DtHelpCeFreeStringArray(
258 _DtCvCellIdsOfTableSeg(seg_list));
261 * free the column justification and width.
263 free((void *) _DtCvColJustifyOfTableSeg(seg_list));
264 strs = _DtCvColWOfTableSeg(seg_list);
266 NULL != strs && i < _DtCvNumColsOfTableSeg(seg_list);
268 free((void *) *strs);
269 if (NULL != _DtCvColWOfTableSeg(seg_list))
270 free((void *) _DtCvColWOfTableSeg(seg_list));
275 CheckFreePrivInfo(seg_list);
276 if (True == TopFlag(seg_list))
278 FreePrivateAndSeg(topSeg);
284 FreePrivateAndSeg(topSeg);
286 } /* End _DtHelpFreeSegments */
288 /*****************************************************************************
289 * Function: void _DtHelpDestroyTopicData (
290 * _DtCvSegment *seg_list)
293 * seg_list Specifies the SDL segment list.
297 * Purpose: Free all memory associated with an SDL list.
298 *****************************************************************************/
300 _DtHelpDestroyTopicData (
301 _DtCvTopicInfo *topic,
302 void (*destroy_region)(),
303 _DtCvPointer client_data)
308 * free the segment list
310 _DtHelpFreeSegments(topic->seg_list, _DtCvFALSE,
311 destroy_region, client_data);
316 if (NULL != topic->id_str)
322 _DtLinkDbDestroy(topic->link_data);
330 } /* End _DtHelpDestroyTopicData */