180c180,186 < return (HTAnchor *) foundAnchor; --- > /* 2001/04/22: Begin bug fix by Michel Philip > HTAnchor_findAddress must not share its anchor but only the address. > It must behave as if the address was not found except that > it's not needed to put a new entry in the adult_table */ > //return (HTAnchor *) foundAnchor; > newaddr = foundAnchor->address; /* Node found : remember the address. */ > break; 184c190,196 < /* Node not found : create new anchor. */ --- > /* Node not found : create new anchor to put in adult_table. */ > if ( foundAnchor == NULL ) { > foundAnchor = HTParentAnchor_new(); > foundAnchor->address = newaddr; /* use the requested address. */ > HTList_addObject (adults, foundAnchor); > } > /* Node found or not : create new anchor for the caller. */ 186,187c198,200 < foundAnchor->address = newaddr; /* Remember our copy */ < HTList_addObject (adults, foundAnchor); --- > foundAnchor->address = newaddr; > /* 2001/04/22: End bug fix by Michel Philip > //HTList_addObject (adults, foundAnchor); */ 305,306c318,320 < /* Deletes all the memory allocated in a parent anchor and returns any < ** hyperdoc object hanging of this anchor --- > /* Deletes all the memory allocated in a parent anchor except > ** the shared address. > ** (2001/04/22: Bug fix by Michel Philip ) 333c347,353 < HT_FREE(me->address); --- > /* 2001/04/22: Bug fix by Michel Philip > 'delete_parent' function can't remove the reference to address > because it is shared by all anchors in the global adult_table > while 'delete_parent' is a recursively called function. > */ > //HT_FREE(me->address); > me->address = NULL; 512,542c532,540 < /* 2001/03/06: Bug fix by Serge Adda < HTAnchor_delete wasn't removing the reference to the deleted < anchor. This caused a bug whenever requesting another anchor < for the same URL. < */ < if (adult_table) { < int hash; < const char *p; < HTList * adults; < HTList * grownups; < HTList * last; < HTParentAnchor * foundAnchor; < < /* Select list from hash table */ < for(p=me->address, hash=0; *p; p++) < hash = (int) ((hash * 3 + (*(unsigned char*)p)) % < PARENT_HASH_SIZE); < adults = adult_table[hash]; < < /* Search list for anchor */ < grownups = adults; < last = grownups; < while ((foundAnchor = (HTParentAnchor *) < HTList_nextObject(grownups))){ < if (!strcmp(foundAnchor->address, me->address)) { < HTList_quickRemoveElement (grownups, last); < break; < } < last = grownups; < } < } --- > /* 2001/04/22: Bug fix by Michel Philip > HTAnchor_delete can't remove the references in the adult_table > because it is a global table shared by all anchors while HTAnchor_delete > is a recursive function removing just an anchor and it's children. > The code of previous committed patch is not bugged in itself > but it bug anyway as soon there is there is at least two times > the same anchor in the requested web page. > This is because of another bug which is in HTAnchor_findAddress. > Note also that a we loose the addresse. */ 1435a1434,1468 > > /* Clear Every Requests Shared Adresses > ** ------------------------------------ > ** Remind you must call HTAnchor_delete before you can safely > ** call this function. > ** If you call HTAnchor_delete after calling this function you will core dump. > ** If you don't call HTAnchor_delete and call HTTPRequest_free > ** you will get infinitely growing memory. > ** Also remind that if you had started multiple requests > ** you must wait all requests are done and had called HTAnchor_delete > ** for each requests before you can safely call this function. > ** Finally notes that you normally don't need to call this function because > ** even if you are sweeping all the web, adult it can't grow infinitely. > */ > PUBLIC void HTAnchor_clearAddresses (void) > { > if (adult_table) { > int hash; > /* Select list from hash table */ > for(hash=0; hash HTList *current = adult_table[hash]; > HTList *last = current; > HTParentAnchor *anchor; > > /* Search list for anchor */ > while ( (anchor = (HTParentAnchor *)HTList_nextObject(current)) ) > { > HT_FREE(anchor->address); > HTList_quickRemoveElement (current, last); > last = current; > } > } > } > } >