-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: libhashtable
action: commit
revision:
path_from:
revision_from: 4c0e3f77d79a31d07f7af220ed752dc12424c58c:
path_to:
revision_to:

git.thebackupbox.net

libhashtable

git://git.thebackupbox.net/libhashtable

commit 4c0e3f77d79a31d07f7af220ed752dc12424c58c
Author: epoch <epoch@hack.thebackupbox.net>
Date:   Fri May 15 08:22:34 2020 +0000

    made ll_freevalues recurse instead of using the ll_destroy if had for some reason I do not remember

diff --git a/libhashtable.c b/libhashtable.c

index ddb7fb072f3d50fb674125b6a6a33c475d9afb28..

index ..f333c24480663229119c138ffc569366c96f85ea 100644

--- a/libhashtable.c
+++ b/libhashtable.c
@@ -144,6 +144,7 @@ void ll_destroy(struct entry *ll) {
  free(ll);
 }

+//this is to just free the buckets and the linked list structs
 void ht_destroy(struct hashtable *ht) {
  int i=0;
  for(i=0;i<ht->kl;i++) {
@@ -153,14 +154,17 @@ void ht_destroy(struct hashtable *ht) {
 }

 void ll_freevalues(struct entry *ll) {//only use if you malloc your table.
- if(ll->next) ll_destroy(ll->next);
+ if(!ll) return;
+ if(ll->next) ll_freevalues(ll->next);
  free(ll->target);
 }

 void ht_freevalues(struct hashtable *ht) {
  int i;
  for(i=0;i<ht->kl;i++) {
-  ll_freevalues(ht->bucket[ht->keys[i]]->ll);
+  if(ht->bucket[ht->keys[i]]) {
+    ll_freevalues(ht->bucket[ht->keys[i]]->ll);
+  }
  }
 }

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 10:31:37 2024