From c00cc63dc2546a1aff16c3530596278ba495f5e3 Mon Sep 17 00:00:00 2001 From: joye Date: Wed, 9 Jul 2014 19:22:06 +0000 Subject: *** empty log message *** --- src/bltChain.C | 176 ++++++++++++++++++++++++-------------------------- src/bltChain.h | 42 ++++++------ src/bltGrAxis.C | 16 ++--- src/bltGrElem.C | 4 +- src/bltGrElemBar.C | 6 +- src/bltGrElemLine.C | 12 ++-- src/bltGrElemOp.C | 32 ++++----- src/bltGrElemOption.C | 4 +- src/bltGrLegd.C | 10 +-- src/bltGrMarker.C | 2 +- src/bltGrMarkerOp.C | 8 +-- src/bltGrXAxisOp.C | 10 +-- src/bltGraph.C | 18 +++--- src/bltGraphBar.C | 2 +- src/bltGraphLine.C | 2 +- src/bltVector.C | 16 ++--- 16 files changed, 180 insertions(+), 180 deletions(-) diff --git a/src/bltChain.C b/src/bltChain.C index 9752b05..3449479 100644 --- a/src/bltChain.C +++ b/src/bltChain.C @@ -38,135 +38,102 @@ using namespace Blt; (((size_t)a + (sizeof(double) - 1)) & (~(sizeof(double) - 1))) #endif -Chain* Blt::Chain_Create(void) +Chain::Chain() { - Chain* chainPtr =(Chain*)malloc(sizeof(Chain)); - if (chainPtr) - Chain_Init(chainPtr); - - return chainPtr; + head_ =NULL; + tail_ =NULL; + nLinks_ =0; } -ChainLink* Blt::Chain_AllocLink(size_t extraSize) +Chain::~Chain() { - size_t linkSize = ALIGN(sizeof(ChainLink)); - ChainLink* linkPtr = (ChainLink*)calloc(1, linkSize + extraSize); - if (extraSize > 0) { - // Point clientData at the memory beyond the normal structure - linkPtr->clientData = ((char *)linkPtr + linkSize); + ChainLink* linkPtr = head_; + while (linkPtr) { + ChainLink* oldPtr =linkPtr; + linkPtr = linkPtr->next; + free(oldPtr); } - - return linkPtr; -} - -void Blt::Chain_InitLink(ChainLink* linkPtr) -{ - linkPtr->clientData = NULL; - linkPtr->next = linkPtr->prev = NULL; } -ChainLink* Blt::Chain_NewLink(void) +void Chain::reset() { - ChainLink* linkPtr = (ChainLink*)malloc(sizeof(ChainLink)); - linkPtr->clientData = NULL; - linkPtr->next = linkPtr->prev = NULL; - return linkPtr; -} - -void Blt::Chain_Reset(Chain* chainPtr) -{ - if (chainPtr) { - ChainLink* oldPtr; - ChainLink* linkPtr = chainPtr->head; - - while (linkPtr) { - oldPtr = linkPtr; - linkPtr = linkPtr->next; - free(oldPtr); - } - Chain_Init(chainPtr); + ChainLink* linkPtr = head_; + while (linkPtr) { + ChainLink* oldPtr = linkPtr; + linkPtr = linkPtr->next; + free(oldPtr); } + head_ =NULL; + tail_ =NULL; + nLinks_ =0; } -void Blt::Chain_Destroy(Chain* chainPtr) +void Chain::linkAfter(ChainLink* linkPtr, ChainLink* afterPtr) { - if (chainPtr) { - Chain_Reset(chainPtr); - free(chainPtr); - chainPtr = NULL; + if (!head_) { + head_ = linkPtr; + tail_ = linkPtr; } -} - -void Blt::Chain_Init(Chain* chainPtr) -{ - chainPtr->nLinks = 0; - chainPtr->head = chainPtr->tail = NULL; -} - -void Blt::Chain_LinkAfter(Chain* chainPtr, ChainLink* linkPtr, - ChainLink* afterPtr) -{ - if (chainPtr->head == NULL) - chainPtr->tail = chainPtr->head = linkPtr; else { - if (afterPtr == NULL) { - // Append to the end of the chain + if (!afterPtr) { linkPtr->next = NULL; - linkPtr->prev = chainPtr->tail; - chainPtr->tail->next = linkPtr; - chainPtr->tail = linkPtr; + linkPtr->prev = tail_; + tail_->next = linkPtr; + tail_ = linkPtr; } else { linkPtr->next = afterPtr->next; linkPtr->prev = afterPtr; - if (afterPtr == chainPtr->tail) - chainPtr->tail = linkPtr; + if (afterPtr == tail_) + tail_ = linkPtr; else afterPtr->next->prev = linkPtr; afterPtr->next = linkPtr; } } - chainPtr->nLinks++; + + nLinks_++; } -void Blt::Chain_LinkBefore(Chain* chainPtr, ChainLink* linkPtr, - ChainLink* beforePtr) +void Chain::linkBefore(ChainLink* linkPtr, ChainLink* beforePtr) { - if (chainPtr->head == NULL) - chainPtr->tail = chainPtr->head = linkPtr; + if (!head_) { + head_ = linkPtr; + tail_ = linkPtr; + } else { if (beforePtr == NULL) { - // Prepend to the front of the chain - linkPtr->next = chainPtr->head; + linkPtr->next = head_; linkPtr->prev = NULL; - chainPtr->head->prev = linkPtr; - chainPtr->head = linkPtr; + head_->prev = linkPtr; + head_ = linkPtr; } else { linkPtr->prev = beforePtr->prev; linkPtr->next = beforePtr; - if (beforePtr == chainPtr->head) - chainPtr->head = linkPtr; + if (beforePtr == head_) + head_ = linkPtr; else beforePtr->prev->next = linkPtr; beforePtr->prev = linkPtr; } } - chainPtr->nLinks++; + + nLinks_++; } -void Blt::Chain_UnlinkLink(Chain* chainPtr, ChainLink* linkPtr) +void Chain::unlinkLink(ChainLink* linkPtr) { // Indicates if the link is actually remove from the chain int unlinked; unlinked = 0; - if (chainPtr->head == linkPtr) { - chainPtr->head = linkPtr->next; + if (head_ == linkPtr) { + head_ = linkPtr->next; unlinked = 1; } - if (chainPtr->tail == linkPtr) { - chainPtr->tail = linkPtr->prev; + if (tail_ == linkPtr) { + tail_ = linkPtr->prev; unlinked = 1; } if (linkPtr->next) { @@ -177,35 +144,62 @@ void Blt::Chain_UnlinkLink(Chain* chainPtr, ChainLink* linkPtr) linkPtr->prev->next = linkPtr->next; unlinked = 1; } - if (unlinked) { - chainPtr->nLinks--; - } - linkPtr->prev = linkPtr->next = NULL; + if (unlinked) + nLinks_--; + + linkPtr->prev =NULL; + linkPtr->next =NULL; } -void Blt::Chain_DeleteLink(Chain* chain, ChainLink* link) +void Chain::deleteLink(ChainLink* link) { - Chain_UnlinkLink(chain, link); + unlinkLink(link); free(link); link = NULL; } -ChainLink* Blt::Chain_Append(Chain* chain, void* clientData) +ChainLink* Chain::append(void* clientData) { ChainLink* link = Chain_NewLink(); - Chain_LinkAfter(chain, link, NULL); + linkAfter(link, NULL); Chain_SetValue(link, clientData); return link; } -ChainLink* Blt::Chain_Prepend(Chain* chain, void* clientData) +ChainLink* Chain::prepend(void* clientData) { ChainLink* link = Chain_NewLink(); - Chain_LinkBefore(chain, link, NULL); + linkBefore(link, NULL); Chain_SetValue(link, clientData); return link; } +ChainLink* Blt::Chain_AllocLink(size_t extraSize) +{ + size_t linkSize = ALIGN(sizeof(ChainLink)); + ChainLink* linkPtr = (ChainLink*)calloc(1, linkSize + extraSize); + if (extraSize > 0) { + // Point clientData at the memory beyond the normal structure + linkPtr->clientData = ((char *)linkPtr + linkSize); + } + + return linkPtr; +} + +void Blt::Chain_InitLink(ChainLink* linkPtr) +{ + linkPtr->clientData = NULL; + linkPtr->next = linkPtr->prev = NULL; +} + +ChainLink* Blt::Chain_NewLink(void) +{ + ChainLink* linkPtr = (ChainLink*)malloc(sizeof(ChainLink)); + linkPtr->clientData = NULL; + linkPtr->next = linkPtr->prev = NULL; + return linkPtr; +} + int Blt::Chain_IsBefore(ChainLink* firstPtr, ChainLink* lastPtr) { for (ChainLink* linkPtr = firstPtr; linkPtr; linkPtr = linkPtr->next) diff --git a/src/bltChain.h b/src/bltChain.h index 70bd266..df55c7c 100644 --- a/src/bltChain.h +++ b/src/bltChain.h @@ -32,16 +32,14 @@ #ifndef _BLT_CHAIN_H #define _BLT_CHAIN_H -#define Chain_GetLength(c) (((c) == NULL) ? 0 : (c)->nLinks) -#define Chain_FirstLink(c) (((c) == NULL) ? NULL : (c)->head) -#define Chain_LastLink(c) (((c) == NULL) ? NULL : (c)->tail) +#define Chain_GetLength(c) (((c) == NULL) ? 0 : (c)->nLinks()) +#define Chain_FirstLink(c) (((c) == NULL) ? NULL : (c)->head()) +#define Chain_LastLink(c) (((c) == NULL) ? NULL : (c)->tail()) #define Chain_PrevLink(l) ((l)->prev) #define Chain_NextLink(l) ((l)->next) #define Chain_GetValue(l) ((l)->clientData) #define Chain_FirstValue(c) (((c)->head == NULL) ? NULL : (c)->head->clientData) #define Chain_SetValue(l, v) ((l)->clientData = (void*)(v)) -#define Chain_AppendLink(c, l) (Chain_LinkAfter((c), (l), (ChainLink*)NULL)) -#define Chain_PrependLink(c, l) (Chain_LinkBefore((c), (l), (ChainLink*)NULL)) namespace Blt { @@ -51,25 +49,33 @@ namespace Blt { void* clientData; }; - struct Chain { - ChainLink* head; - ChainLink* tail; - long nLinks; + class Chain { + protected: + ChainLink* head_; + ChainLink* tail_; + long nLinks_; + + public: + Chain(); + virtual ~Chain(); + + ChainLink* head() {return head_;} + ChainLink* tail() {return tail_;} + long nLinks() {return nLinks_;} + + void reset(); + void linkAfter(ChainLink* link, ChainLink* after); + void linkBefore(ChainLink* link, ChainLink* before); + void unlinkLink(ChainLink* linkPtr); + void deleteLink(ChainLink* link); + ChainLink* append(void* clientData); + ChainLink* prepend(void* clientData); }; - extern Chain* Chain_Create(void); extern ChainLink* Chain_AllocLink(size_t size); extern void Chain_InitLink(ChainLink* link); extern void Chain_Init(Chain* chain); extern ChainLink* Chain_NewLink(void); - extern void Chain_Reset(Chain* chain); - extern void Chain_Destroy(Chain* chain); - extern void Chain_LinkAfter(Chain* chain, ChainLink* link, ChainLink* after); - extern void Chain_LinkBefore(Chain* chain, ChainLink* link,ChainLink* before); - extern void Chain_UnlinkLink(Chain* chain, ChainLink* link); - extern void Chain_DeleteLink(Chain* chain, ChainLink* link); - extern ChainLink* Chain_Append(Chain* chain, void* clientData); - extern ChainLink* Chain_Prepend(Chain* chain, void* clientData); extern int Chain_IsBefore(ChainLink* first, ChainLink* last); }; diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C index f3ce8bb..8edaac5 100644 --- a/src/bltGrAxis.C +++ b/src/bltGrAxis.C @@ -260,7 +260,7 @@ Axis::Axis(Graph* graphPtr, const char* name, int margin, Tcl_HashEntry* hPtr) margin_ = margin; segments_ =NULL; nSegments_ =0; - tickLabels_ = Chain_Create(); + tickLabels_ = new Chain(); left_ =0; right_ =0; top_ =0; @@ -299,7 +299,7 @@ Axis::~Axis() graphPtr_->bindTable_->deleteBindings(this); if (link) - Chain_DeleteLink(chain, link); + chain->deleteLink(link); if (hashPtr_) Tcl_DeleteHashEntry(hashPtr_); @@ -332,7 +332,7 @@ Axis::~Axis() freeTickLabels(); - Chain_Destroy(tickLabels_); + delete tickLabels_; if (segments_) delete [] segments_; @@ -421,19 +421,19 @@ void Axis::mapStacked(int count, int margin) AxisOptions* ops = (AxisOptions*)ops_; GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; - if ((gops->margins[margin_].axes->nLinks > 1) || + if ((gops->margins[margin_].axes->nLinks() > 1) || (ops->reqNumMajorTicks <= 0)) { ops->reqNumMajorTicks = 4; } unsigned int slice; if (isHorizontal()) { - slice = graphPtr_->hRange_ / gops->margins[margin].axes->nLinks; + slice = graphPtr_->hRange_ / gops->margins[margin].axes->nLinks(); screenMin_ = graphPtr_->hOffset_; width_ = slice; } else { - slice = graphPtr_->vRange_ / gops->margins[margin].axes->nLinks; + slice = graphPtr_->vRange_ / gops->margins[margin].axes->nLinks(); screenMin_ = graphPtr_->vOffset_; height_ = slice; } @@ -1033,7 +1033,7 @@ void Axis::freeTickLabels() TickLabel* labelPtr = (TickLabel*)Chain_GetValue(link); delete labelPtr; } - Chain_Reset(chain); + chain->reset(); } TickLabel* Axis::makeLabel(double value) @@ -1904,7 +1904,7 @@ void Axis::getGeometry() continue; TickLabel* labelPtr = makeLabel(x); - Chain_Append(tickLabels_, labelPtr); + tickLabels_->append(labelPtr); nLabels++; // Get the dimensions of each tick label. Remember tick labels diff --git a/src/bltGrElem.C b/src/bltGrElem.C index 94a922e..018a4f1 100644 --- a/src/bltGrElem.C +++ b/src/bltGrElem.C @@ -194,7 +194,7 @@ Element::~Element() graphPtr_->bindTable_->deleteBindings(this); if (link) - Chain_DeleteLink(graphPtr_->elements_.displayList, link); + graphPtr_->elements_.displayList->deleteLink(link); if (hashPtr_) Tcl_DeleteHashEntry(hashPtr_); @@ -280,7 +280,7 @@ void Element::freeStylePalette(Chain* stylePalette) if (penPtr->refCount_ == 0) delete penPtr; } - Chain_DeleteLink(stylePalette, link); + stylePalette->deleteLink(link); } } } diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C index 4fe0439..ed5ca77 100644 --- a/src/bltGrElemBar.C +++ b/src/bltGrElemBar.C @@ -199,7 +199,7 @@ BarElement::BarElement(Graph* graphPtr, const char* name, Tcl_HashEntry* hPtr) optionTable_ = Tk_CreateOptionTable(graphPtr->interp_, optionSpecs); - ops->stylePalette = Chain_Create(); + ops->stylePalette = new Chain(); // this is an option and will be freed via Tk_FreeConfigOptions // By default an element's name and label are the same @@ -222,7 +222,7 @@ BarElement::~BarElement() if (ops->stylePalette) { freeStylePalette(ops->stylePalette); - Chain_Destroy(ops->stylePalette); + delete ops->stylePalette; } } @@ -237,7 +237,7 @@ int BarElement::configure() ChainLink* link = Chain_FirstLink(ops->stylePalette); if (!link) { link = Chain_AllocLink(sizeof(BarStyle)); - Chain_LinkAfter(ops->stylePalette, link, NULL); + ops->stylePalette->linkAfter(link, NULL); } BarStyle* stylePtr = (BarStyle*)Chain_GetValue(link); stylePtr->penPtr = NORMALPEN(ops); diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C index 5a8fa2c..b8e37a1 100644 --- a/src/bltGrElemLine.C +++ b/src/bltGrElemLine.C @@ -250,7 +250,7 @@ LineElement::LineElement(Graph* graphPtr, const char* name, Tcl_HashEntry* hPtr) optionTable_ = Tk_CreateOptionTable(graphPtr->interp_, optionSpecs); - ops->stylePalette = Chain_Create(); + ops->stylePalette = new Chain(); // this is an option and will be freed via Tk_FreeConfigOptions // By default an element's name and label are the same ops->label = Tcl_Alloc(strlen(name)+1); @@ -272,7 +272,7 @@ LineElement::~LineElement() if (ops->stylePalette) { freeStylePalette(ops->stylePalette); - Chain_Destroy(ops->stylePalette); + delete ops->stylePalette; } if (fillPts_) @@ -291,7 +291,7 @@ int LineElement::configure() ChainLink* link = Chain_FirstLink(ops->stylePalette); if (!link) { link = Chain_AllocLink(sizeof(LineStyle)); - Chain_LinkAfter(ops->stylePalette, link, NULL); + ops->stylePalette->linkAfter(link, NULL); } LineStyle* stylePtr = (LineStyle*)Chain_GetValue(link); stylePtr->penPtr = NORMALPEN(ops); @@ -1533,9 +1533,9 @@ void LineElement::saveTrace(int start, int length, MapInfo* mapPtr) tracePtr->screenPts.map = map; tracePtr->start = start; if (traces_ == NULL) - traces_ = Chain_Create(); + traces_ = new Chain(); - Chain_Append(traces_, tracePtr); + traces_->append(tracePtr); } void LineElement::freeTraces() @@ -1547,7 +1547,7 @@ void LineElement::freeTraces() delete [] tracePtr->screenPts.points; delete tracePtr; } - Chain_Destroy(traces_); + delete traces_; traces_ = NULL; } diff --git a/src/bltGrElemOp.C b/src/bltGrElemOp.C index 6fd59d6..47b783c 100644 --- a/src/bltGrElemOp.C +++ b/src/bltGrElemOp.C @@ -356,25 +356,25 @@ static int LowerOp(ClientData clientData, Tcl_Interp* interp, // Move the links of lowered elements out of the display list into // a temporary list - Chain* chain = Chain_Create(); + Chain* chain = new Chain(); for (int ii=3; iigetElement(objv[ii], &elemPtr) != TCL_OK) return TCL_ERROR; - Chain_UnlinkLink(graphPtr->elements_.displayList, elemPtr->link); - Chain_LinkAfter(chain, elemPtr->link, NULL); + graphPtr->elements_.displayList->unlinkLink(elemPtr->link); + chain->linkAfter(elemPtr->link, NULL); } // Append the links to end of the display list ChainLink *link, *next; for (link = Chain_FirstLink(chain); link; link = next) { next = Chain_NextLink(link); - Chain_UnlinkLink(chain, link); - Chain_LinkAfter(graphPtr->elements_.displayList, link, NULL); + chain->unlinkLink(link); + graphPtr->elements_.displayList->linkAfter(link, NULL); } - Chain_Destroy(chain); + delete chain; graphPtr->flags |= CACHE; graphPtr->eventuallyRedraw(); @@ -421,25 +421,25 @@ static int RaiseOp(ClientData clientData, Tcl_Interp* interp, { Graph* graphPtr = (Graph*)clientData; - Chain* chain = Chain_Create(); + Chain* chain = new Chain(); for (int ii=3; iigetElement(objv[ii], &elemPtr) != TCL_OK) return TCL_ERROR; - Chain_UnlinkLink(graphPtr->elements_.displayList, elemPtr->link); - Chain_LinkAfter(chain, elemPtr->link, NULL); + graphPtr->elements_.displayList->unlinkLink(elemPtr->link); + chain->linkAfter(elemPtr->link, NULL); } // Prepend the links to beginning of the display list in reverse order ChainLink *link, *prev; for (link = Chain_LastLink(chain); link; link = prev) { prev = Chain_PrevLink(link); - Chain_UnlinkLink(chain, link); - Chain_LinkBefore(graphPtr->elements_.displayList, link, NULL); + chain->unlinkLink(link); + graphPtr->elements_.displayList->linkBefore(link, NULL); } - Chain_Destroy(chain); + delete chain; graphPtr->flags |= CACHE; graphPtr->eventuallyRedraw(); @@ -461,15 +461,15 @@ static int ShowOp(ClientData clientData, Tcl_Interp* interp, return TCL_ERROR; // Collect the named elements into a list - Chain* chain = Chain_Create(); + Chain* chain = new Chain(); for (int ii=0; iigetElement(elemObjv[ii], &elemPtr) != TCL_OK) { - Chain_Destroy(chain); + delete chain; return TCL_ERROR; } - Chain_Append(chain, elemPtr); + chain->append(elemPtr); } // Clear the links from the currently displayed elements @@ -478,7 +478,7 @@ static int ShowOp(ClientData clientData, Tcl_Interp* interp, Element* elemPtr = (Element*)Chain_GetValue(link); elemPtr->link = NULL; } - Chain_Destroy(graphPtr->elements_.displayList); + delete graphPtr->elements_.displayList; graphPtr->elements_.displayList = chain; // Set links on all the displayed elements diff --git a/src/bltGrElemOption.C b/src/bltGrElemOption.C index 10e0b5c..27c7d08 100644 --- a/src/bltGrElemOption.C +++ b/src/bltGrElemOption.C @@ -243,7 +243,7 @@ int StyleSetProc(ClientData clientData, Tcl_Interp* interp, ChainLink* link = Chain_FirstLink(stylePalette); if (!link) { link = Chain_AllocLink(size); - Chain_LinkAfter(stylePalette, link, NULL); + stylePalette->linkAfter(link, NULL); } PenStyle* stylePtr = (PenStyle*)Chain_GetValue(link); @@ -260,7 +260,7 @@ int StyleSetProc(ClientData clientData, Tcl_Interp* interp, elemPtr->freeStylePalette(stylePalette); return TCL_ERROR; } - Chain_LinkAfter(stylePalette, link, NULL); + stylePalette->linkAfter(link, NULL); } return TCL_OK; diff --git a/src/bltGrLegd.C b/src/bltGrLegd.C index 4047309..a46b50a 100644 --- a/src/bltGrLegd.C +++ b/src/bltGrLegd.C @@ -176,7 +176,7 @@ Legend::Legend(Graph* graphPtr) focusPtr_ =NULL; selAnchorPtr_ =NULL; selMarkPtr_ =NULL; - selected_ = Chain_Create(); + selected_ = new Chain(); titleWidth_ =0; titleHeight_ =0; @@ -215,7 +215,7 @@ Legend::~Legend() if (graphPtr_->tkwin_) Tk_DeleteSelHandler(graphPtr_->tkwin_, XA_PRIMARY, XA_STRING); - Chain_Destroy(selected_); + delete selected_; Tk_FreeConfigOptions((char*)ops_, optionTable_, graphPtr_->tkwin_); free(ops_); @@ -762,7 +762,7 @@ void Legend::selectElement(Element* elemPtr) int isNew; Tcl_HashEntry* hPtr = Tcl_CreateHashEntry(&selectTable_, elemPtr, &isNew); if (isNew) { - ChainLink* link = Chain_Append(selected_, elemPtr); + ChainLink* link = selected_->append(elemPtr); Tcl_SetHashValue(hPtr, link); } } @@ -772,7 +772,7 @@ void Legend::deselectElement(Element* elemPtr) Tcl_HashEntry* hPtr = Tcl_FindHashEntry(&selectTable_, elemPtr); if (hPtr) { ChainLink* link = (ChainLink*)Tcl_GetHashValue(hPtr); - Chain_DeleteLink(selected_, link); + selected_->deleteLink(link); Tcl_DeleteHashEntry(hPtr); } } @@ -806,7 +806,7 @@ void Legend::clearSelection() Tcl_DeleteHashTable(&selectTable_); Tcl_InitHashTable(&selectTable_, TCL_ONE_WORD_KEYS); - Chain_Reset(selected_); + selected_->reset(); if (ops->selectCmd) eventuallyInvokeSelectCmd(); diff --git a/src/bltGrMarker.C b/src/bltGrMarker.C index 1dabb4d..6195a0c 100644 --- a/src/bltGrMarker.C +++ b/src/bltGrMarker.C @@ -57,7 +57,7 @@ Marker::~Marker() graphPtr_->bindTable_->deleteBindings(this); if (link) - Chain_DeleteLink(graphPtr_->markers_.displayList, link); + graphPtr_->markers_.displayList->deleteLink(link); if (hashPtr_) Tcl_DeleteHashEntry(hashPtr_); diff --git a/src/bltGrMarkerOp.C b/src/bltGrMarkerOp.C index 1f5cdd5..d1472d3 100644 --- a/src/bltGrMarkerOp.C +++ b/src/bltGrMarkerOp.C @@ -145,7 +145,7 @@ static int CreateMarker(Graph* graphPtr, Tcl_Interp* interp, } // Unlike elements, new markers are drawn on top of old markers - markerPtr->link = Chain_Prepend(graphPtr->markers_.displayList, markerPtr); + markerPtr->link = graphPtr->markers_.displayList->prepend(markerPtr); Tcl_SetStringObj(Tcl_GetObjResult(interp), name, -1); @@ -391,15 +391,15 @@ static int RelinkOp(ClientData clientData, Tcl_Interp* interp, return TCL_ERROR; ChainLink* link = markerPtr->link; - Chain_UnlinkLink(graphPtr->markers_.displayList, markerPtr->link); + graphPtr->markers_.displayList->unlinkLink(markerPtr->link); ChainLink* place = placePtr ? placePtr->link : NULL; const char* string = Tcl_GetString(objv[2]); if (string[0] == 'l') - Chain_LinkAfter(graphPtr->markers_.displayList, link, place); + graphPtr->markers_.displayList->linkAfter(link, place); else - Chain_LinkBefore(graphPtr->markers_.displayList, link, place); + graphPtr->markers_.displayList->linkBefore(link, place); graphPtr->flags |= CACHE; graphPtr->eventuallyRedraw(); diff --git a/src/bltGrXAxisOp.C b/src/bltGrXAxisOp.C index 75054a4..9bb03bd 100644 --- a/src/bltGrXAxisOp.C +++ b/src/bltGrXAxisOp.C @@ -166,7 +166,7 @@ static int UseOp(ClientData clientData, Tcl_Interp* interp, axisPtr->setClass(CID_NONE); } - Chain_Reset(chain); + chain->reset(); for (int ii=0; iigetAxis(axisObjv[ii], &axisPtr) != TCL_OK) @@ -181,12 +181,12 @@ static int UseOp(ClientData clientData, Tcl_Interp* interp, return TCL_ERROR; } if (axisPtr->link) { - /* Move the axis from the old margin's "use" list to the new. */ - Chain_UnlinkLink(axisPtr->chain, axisPtr->link); - Chain_AppendLink(chain, axisPtr->link); + // Move the axis from the old margin's "use" list to the new + axisPtr->chain->unlinkLink(axisPtr->link); + chain->linkAfter(axisPtr->link, NULL); } else - axisPtr->link = Chain_Append(chain, axisPtr); + axisPtr->link = chain->append(axisPtr); axisPtr->chain = chain; axisPtr->use_ =1; diff --git a/src/bltGraph.C b/src/bltGraph.C index 61778fd..fc0bc86 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -113,9 +113,9 @@ Graph::Graph(ClientData clientData, Tcl_Interp* interp, Tcl_InitHashTable(&markers_.tagTable, TCL_STRING_KEYS); Tcl_InitHashTable(&penTable_, TCL_STRING_KEYS); - axes_.displayList = Chain_Create(); - elements_.displayList = Chain_Create(); - markers_.displayList = Chain_Create(); + axes_.displayList = new Chain(); + elements_.displayList = new Chain(); + markers_.displayList = new Chain(); bindTable_ = new BindTable(this, this); if (createAxes() != TCL_OK) { @@ -656,7 +656,7 @@ void Graph::destroyElements() Tcl_DeleteHashTable(&elements_.table); Tcl_DeleteHashTable(&elements_.tagTable); - Chain_Destroy(elements_.displayList); + delete elements_.displayList; } void Graph::configureElements() @@ -752,7 +752,7 @@ void Graph::destroyMarkers() } Tcl_DeleteHashTable(&markers_.table); Tcl_DeleteHashTable(&markers_.tagTable); - Chain_Destroy(markers_.displayList); + delete markers_.displayList; } @@ -876,7 +876,7 @@ int Graph::createAxes() int isNew; Tcl_HashEntry* hPtr = Tcl_CreateHashEntry(&axes_.table, axisNames[ii].name, &isNew); - Chain* chain = Chain_Create(); + Chain* chain = new Chain(); Axis* axisPtr = new Axis(this, axisNames[ii].name, ii, hPtr); if (!axisPtr) @@ -901,7 +901,7 @@ int Graph::createAxes() ops->hide = 1; axisChain_[ii] = chain; - axisPtr->link = Chain_Append(chain, axisPtr); + axisPtr->link = chain->append(axisPtr); axisPtr->chain = chain; } return TCL_OK; @@ -949,10 +949,10 @@ void Graph::destroyAxes() Tcl_DeleteHashTable(&axes_.table); for (int ii=0; ii<4; ii++) - Chain_Destroy(axisChain_[ii]); + delete axisChain_[ii]; Tcl_DeleteHashTable(&axes_.tagTable); - Chain_Destroy(axes_.displayList); + delete axes_.displayList; } void Graph::configureAxes() diff --git a/src/bltGraphBar.C b/src/bltGraphBar.C index e7075bc..8ac685b 100644 --- a/src/bltGraphBar.C +++ b/src/bltGraphBar.C @@ -278,7 +278,7 @@ int BarGraph::createElement(int objc, Tcl_Obj* const objv[]) return TCL_ERROR; } - elemPtr->link = Chain_Append(elements_.displayList, elemPtr); + elemPtr->link = elements_.displayList->append(elemPtr); return TCL_OK; } diff --git a/src/bltGraphLine.C b/src/bltGraphLine.C index 957d1fa..0faf663 100644 --- a/src/bltGraphLine.C +++ b/src/bltGraphLine.C @@ -236,7 +236,7 @@ int LineGraph::createElement(int objc, Tcl_Obj* const objv[]) return TCL_ERROR; } - elemPtr->link = Chain_Append(elements_.displayList, elemPtr); + elemPtr->link = elements_.displayList->append(elemPtr); return TCL_OK; } diff --git a/src/bltVector.C b/src/bltVector.C index 36d1cb6..955b854 100644 --- a/src/bltVector.C +++ b/src/bltVector.C @@ -763,7 +763,7 @@ Vector* Blt::Vec_New(VectorInterpData *dataPtr) vPtr->length = 0; vPtr->interp = dataPtr->interp; vPtr->hashPtr = NULL; - vPtr->chain = Chain_Create(); + vPtr->chain = new Chain(); vPtr->flush = 0; vPtr->min = vPtr->max = NAN; vPtr->notifyFlags = NOTIFY_WHENIDLE; @@ -795,7 +795,7 @@ void Blt::Vec_Free(Vector* vPtr) VectorClient *clientPtr = (VectorClient*)Chain_GetValue(link); free(clientPtr); } - Chain_Destroy(vPtr->chain); + delete vPtr->chain; if ((vPtr->valueArr != NULL) && (vPtr->freeProc != TCL_STATIC)) { if (vPtr->freeProc == TCL_DYNAMIC) { free(vPtr->valueArr); @@ -1458,7 +1458,7 @@ Blt_VectorId Blt_AllocVectorId(Tcl_Interp* interp, const char *name) clientPtr->magic = VECTOR_MAGIC; /* Add the new client to the server's list of clients */ - clientPtr->link = Chain_Append(vPtr->chain, clientPtr); + clientPtr->link = vPtr->chain->append(clientPtr); clientPtr->serverPtr = vPtr; clientId = (Blt_VectorId) clientPtr; return clientId; @@ -1481,12 +1481,12 @@ void Blt_FreeVectorId(Blt_VectorId clientId) { VectorClient *clientPtr = (VectorClient *)clientId; - if (clientPtr->magic != VECTOR_MAGIC) { - return; /* Not a valid token */ - } + if (clientPtr->magic != VECTOR_MAGIC) + return; + if (clientPtr->serverPtr != NULL) { - /* Remove the client from the server's list */ - Chain_DeleteLink(clientPtr->serverPtr->chain, clientPtr->link); + // Remove the client from the server's list + clientPtr->serverPtr->chain->deleteLink(clientPtr->link); } free(clientPtr); } -- cgit v0.12