According to Geoff Hutchison:
> Sigh. I should probably cook up a test program for HtVector and HtHeap
> again, but I think it's time to grab some sleep.
>
> The following are some patches that start to convert the indexing to sort
> based on hopcount. Right now it works in the single server case, but I
> need to make the list of servers into a heap so it works in the multiple
> server case.
>
> The problem seems to be that HtHeap/HtVector isn't freeing memory
> correctly.
I took a look (a quick look, mind you) and didn't find anything wrong
with the memory allocation and freeing.
> Since I fixed one bug in HtHeap already, I'm assuming these "phantom" URLs
> are simply URLRef's that have not been properly freed. If someone can spot
> the program, I'd be very greatful (Offhand, I'd guess it's in HtVector.)
Even if you had Objects that weren't getting freed, that should just chew
up extra memory, but not cause the memory that you are using to get clobbered.
I'm wondering if your problems aren't somehow related to the segmentation
faults I've been getting.
> Index: htlib/HtHeap.cc
> ===================================================================
> RCS file: /opt/htdig/cvs/htdig3/htlib/HtHeap.cc,v
> retrieving revision 1.2
> diff -c -3 -p -r1.2 HtHeap.cc
> *** htlib/HtHeap.cc 1999/03/14 03:26:21 1.2
> --- htlib/HtHeap.cc 1999/08/11 03:39:13
> *************** Object *HtHeap::Remove()
> *** 92,98 ****
> {
> Object *min = Peek();
>
> ! data->RemoveFrom(data->Count() - 1);
>
> if (data->Count() > 1)
> pushDownRoot(0);
> --- 92,98 ----
> {
> Object *min = Peek();
>
> ! data->RemoveFrom(0);
>
> if (data->Count() > 1)
> pushDownRoot(0);
>
Is this patch the bug fix in HtHeap you mentioned above? If so, it
hasn't been committed to CVS yet. I found a couple minor problems in
HtVector. In its Last and Index methods, it seemed to be overstepping
the array bounds. I've also added some bounds checking to Last and Nth.
I haven't committed these changes, because I wanted you to have a look
at them first. I'm not sure I'm doing the right thing here, as it's
unfamiliar code.
--- htlib/HtVector.h.bak Wed Apr 14 14:39:12 1999
+++ htlib/HtVector.h Mon Aug 16 16:35:57 1999
@@ -79,14 +79,14 @@ public:
Object *Get_First();
Object *Next(Object *current);
Object *Previous(Object *current);
- Object *Last() {return data[element_count];}
+ Object *Last() {return element_count<=0?(Object
+*)NULL:data[element_count-1];}
//
// Direct access to vector items. To assign new objects, use
// Insert() or Add() or Assign()
//
- Object *operator[] (int n) {return data[n];}
- Object *Nth(int n) {return data[n];}
+ Object *operator[] (int n) {return
+(n<0||n>=element_count)?(Object *)NULL:data[n];}
+ Object *Nth(int n) {return
+(n<0||n>=element_count)?(Object *)NULL:data[n];}
//
// Access to the number of elements
--- htlib/HtVector.cc.bak Mon Feb 22 07:57:55 1999
+++ htlib/HtVector.cc Mon Aug 16 15:36:04 1999
@@ -209,7 +209,7 @@ int HtVector::Index(Object *obj)
{
int index = 0;
- while (index <= element_count && data[index] != obj)
+ while (index < element_count && data[index] != obj)
{
index++;
}
In any case, there are memory problems elsewhere.
--
Gilles R. Detillieux E-mail: <[EMAIL PROTECTED]>
Spinal Cord Research Centre WWW: http://www.scrc.umanitoba.ca/~grdetil
Dept. Physiology, U. of Manitoba Phone: (204)789-3766
Winnipeg, MB R3E 3J7 (Canada) Fax: (204)789-3930
------------------------------------
To unsubscribe from the htdig3-dev mailing list, send a message to
[EMAIL PROTECTED] containing the single word "unsubscribe" in
the SUBJECT of the message.