/********************************************************************* * Function: _DtHelpDisplayAreaDestroyCB * * _DtHelpDisplayAreaDestroyCB deallocates all information * associated with it. * *********************************************************************/ void _DtHelpDisplayAreaDestroyCB ( Widget w, XtPointer client_data, XtPointer call_data) { int i; long strIdx; XrmName xrmList[_DtHelpFontQuarkNumber]; Display *dpy; DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data; Boolean usedDef = False; /* * do the gross cleaning */ _DtHelpDisplayAreaClean(client_data); if (NULL != pDAS->canvas) _DtCanvasDestroy (pDAS->canvas); dpy = XtDisplay(pDAS->dispWid); /* * Free the gc's */ XFreeGC (dpy, pDAS->normalGC); XFreeGC (dpy, pDAS->pixmapGC); XFreeGC (dpy, pDAS->invertGC); if (pDAS->def_pix != 0 && XmDestroyPixmap(XDefaultScreenOfDisplay(dpy), pDAS->def_pix) == False) XFreePixmap(dpy, pDAS->def_pix); if (pDAS->context != NULL) { _DtGrDestroyContext(pDAS->context); XtFree((char *) pDAS->context); } /* * destroy the widgets. */ XtDestroyWidget(pDAS->dispWid); if (pDAS->horzScrollWid != NULL) XtDestroyWidget(pDAS->horzScrollWid); if (pDAS->vertScrollWid != NULL) XtDestroyWidget(pDAS->vertScrollWid); /* * free the special characters */ if (pDAS->spc_chars != NULL) free ((char *) pDAS->spc_chars); /* * free the font info. */ _DtHelpGetStringQuarks(xrmList); if (__DtHelpFontIndexGet(pDAS, xrmList, &strIdx) != 0) usedDef = True; if (pDAS->font_info.def_font_db != NULL) XrmDestroyDatabase(pDAS->font_info.def_font_db); if (pDAS->font_info.font_idx_db != NULL) XrmDestroyDatabase(pDAS->font_info.font_idx_db); if (pDAS->font_info.exact_fonts != NULL) { _DtHelpCeFreeStringArray(pDAS->font_info.exact_fonts); free(pDAS->font_info.exact_idx); } if (pDAS->font_info.font_structs != NULL) { /* * if the string index is a positive number, this * indicates that the string font is a font not * a font set and it wouldn't be freed in this * routine. */ for (i = 0; i < pDAS->font_info.struct_cnt; i++) { if (usedDef == True || i != strIdx) XFreeFont(dpy, pDAS->font_info.font_structs[i]); } free(pDAS->font_info.font_structs); } if (pDAS->font_info.font_sets != NULL) { /* * if the string index is a negative number, this turns * it to positive and the tests will succeed. * * if the string index was a font not a fontset, then * this will turn the value negative and the test * will never succeed. */ strIdx = (-strIdx) - 1; for (i = 0; i < pDAS->font_info.set_cnt; i++) { if (usedDef == True || i != strIdx) XFreeFontSet(dpy, pDAS->font_info.font_sets[i]); } free(pDAS->font_info.font_sets); free(pDAS->font_info.fs_metrics); } /* * free the locale dependant information */ if (NULL != pDAS->cant_begin_chars) free (pDAS->cant_begin_chars); if (NULL != pDAS->cant_end_chars) free (pDAS->cant_end_chars); /* * destroy the display area pointer */ XtFree ((char *) pDAS); } /* End DtHelpDisplayAreaDestroy */
/***************************************************************************** * Function: void _DtHelpFreeSegments (_DtCvSegment *seg_list) * * Parameters: * seg_list Specifies the Canvas Engine segment list. * * Returns: Nothing * * Purpose: Free all memory associated with an SDL list. *****************************************************************************/ void _DtHelpFreeSegments ( _DtCvSegment *seg_list, _DtCvStatus unresolved, void (*destroy_region)(), _DtCvPointer client_data) { int i; char dupFlag; char **strs; _DtCvSegment *nextSeg; _DtCvSegment *topSeg = NULL; _DtCvSegment *topTab = NULL; _DtCvSegment **tableSeg; while (seg_list != NULL) { dupFlag = DupFlag(seg_list); nextSeg = seg_list->next_seg; switch (_DtCvPrimaryTypeOfSeg(seg_list)) { case _DtCvCONTAINER: /* * free the id block. */ if (False == dupFlag && NULL != _DtCvContainerIdOfSeg(seg_list)) free(_DtCvContainerIdOfSeg(seg_list)); /* * free the contents of the block */ _DtHelpFreeSegments(_DtCvContainerListOfSeg(seg_list), unresolved, destroy_region, client_data); break; case _DtCvMARKER: if (False == dupFlag) free(_DtCvIdOfMarkerSeg(seg_list)); break; case _DtCvREGION: if (False == dupFlag && NULL != destroy_region) (destroy_region)(client_data, _DtCvInfoOfRegionSeg(seg_list)); break; case _DtCvSTRING: if (False == dupFlag) { free(_DtCvStringOfStringSeg(seg_list)); if (True == unresolved && NULL != _DtCvFontOfStringSeg(seg_list)) free(_DtCvFontOfStringSeg(seg_list)); } break; case _DtCvTABLE: if (True == dupFlag) break; /* * free the blocks */ tableSeg = _DtCvCellsOfTableSeg(seg_list); while (NULL != tableSeg && NULL != *tableSeg) { /* * free the id block. */ if (False == DupFlag(*tableSeg) && NULL != _DtCvContainerIdOfSeg(*tableSeg)) free(_DtCvContainerIdOfSeg(*tableSeg)); /* * free the contents of the block */ _DtHelpFreeSegments( _DtCvContainerListOfSeg(*tableSeg), unresolved, destroy_region, client_data); tableSeg++; } /* * free each of the table cells */ tableSeg = _DtCvCellsOfTableSeg(seg_list); while (NULL != tableSeg && NULL != *tableSeg) { if (True == TopFlag(*tableSeg)) { FreePrivateAndSeg(topTab); topTab = *tableSeg; } CheckFreePrivInfo(*tableSeg); tableSeg++; } FreePrivateAndSeg(topTab); topTab = NULL; /* * free the list of cells */ tableSeg = _DtCvCellsOfTableSeg(seg_list); free (tableSeg); /* * free the row ids. */ _DtHelpCeFreeStringArray( _DtCvCellIdsOfTableSeg(seg_list)); /* * free the column justification and width. */ free((void *) _DtCvColJustifyOfTableSeg(seg_list)); strs = _DtCvColWOfTableSeg(seg_list); for (i = 0; NULL != strs && i < _DtCvNumColsOfTableSeg(seg_list); i++, strs++) free((void *) *strs); if (NULL != _DtCvColWOfTableSeg(seg_list)) free((void *) _DtCvColWOfTableSeg(seg_list)); break; } CheckFreePrivInfo(seg_list); if (True == TopFlag(seg_list)) { FreePrivateAndSeg(topSeg); topSeg = seg_list; } seg_list = nextSeg; } FreePrivateAndSeg(topSeg); } /* End _DtHelpFreeSegments */
/****************************************************************************** * Function: int ProcessEntry (_DtHelpVolume vol) * * Parameters: vol Specifies the volume whose keywords need to be * loaded from disk. Once loaded, they can be * accessed through the fields of the volume structure. * * Return Value: 0 if successful, -1 if a failure occurs * * errno Values: CEErrorMalloc * CEErrorIllegalDatabaseFile * Specifies that the keyword file is * invalid or corrupt. * CEErrorMissingKeywordsRes * Specifies that the keyword file does * not contain the 'Keywords/keywords' * resource or the resource is NULL * * * Purpose: Load the keywords associated with a volume. * ******************************************************************************/ static int ProcessEntry ( _DtHelpVolume vol, _DtCvSegment *p_seg, char *parent_key) { int strSize; char **topics; char *nextKey = NULL; /* Now parse the string into the appropriate arrays. The string has the following syntax: <!ELEMENT entry - - ((%simple; | #PCDATA)*, entry*) > <!ATTLIST entry id ID #IMPLIED main IDREFS #IMPLIED locs IDREFS #IMPLIED syns IDREFS #IMPLIED sort CDATA #IMPLIED > */ #define MAIN_STRINGS (_SdlSegToSdlEntryInfo(p_seg))->main #define LOCS_STRINGS (_SdlSegToSdlEntryInfo(p_seg))->locs while (p_seg != NULL) { strSize = 0; nextKey = AsciiKeyword(_DtCvContainerListOfSeg(p_seg), parent_key, &strSize); if (nextKey == NULL) return -1; /* We have the next keyword. Hang onto it and add it to the list once we get the array of topics. We don't add it yet because if there are no topics we want to throw it away. (Silently ignoring keywords which specify no topics is an undocumented feature.) */ /* Now get the list of topics. */ topics = NULL; if (NULL != FrmtPrivInfoPtr(p_seg) && NULL != _SdlSegEntryInfo(p_seg) && (ProcessLocations(MAIN_STRINGS, &topics) == -1 || ProcessLocations(LOCS_STRINGS, &topics) == -1)) { free(nextKey); return -1; } if (topics != NULL) { vol->keywords = (char **) _DtHelpCeAddPtrToArray ( (void **) vol->keywords, (void *) nextKey); vol->keywordTopics = (char ***) _DtHelpCeAddPtrToArray ( (void **) vol->keywordTopics, (void *) topics); /* * If we just malloc'ed ourselves out of existance... * stop here. */ if (vol->keywords == 0 || vol->keywordTopics == 0) { if (vol->keywords != NULL) { free(nextKey); _DtHelpCeFreeStringArray (vol->keywords); _DtHelpCeFreeStringArray (topics); vol->keywords = NULL; } if (vol->keywordTopics) { char ***topicList; for (topicList = vol->keywordTopics; topicList; topicList++) _DtHelpCeFreeStringArray (*topicList); free (vol->keywordTopics); vol->keywordTopics = NULL; } return -1; } } if (_DtCvContainerListOfSeg(p_seg) != NULL && ProcessSubEntries(vol,_DtCvContainerListOfSeg(p_seg),nextKey) == -1) return -1; if (topics == NULL) free (nextKey); p_seg = p_seg->next_seg; } return (0); }