Repositories » libk0
Clone URL:  
Pushed to one repository · View In Graph Contained in tip

hlookup() bug fix; the new pointer is returned after adding to the chain.

Changeset 4c21d1817329

Parent 937fc39b5c64

by Rup Palchowdhury

Changes to 2 files · Browse files at 4c21d1817329 Showing diff from parent 937fc39b5c64 Diff from another changeset...

Change 1 of 1 Show Entire File khash.c Stacked
 
20
21
22
23
 
24
25
26
27
28
29
 
 
 
 
30
 
 
31
32
 
20
21
22
 
23
24
25
 
 
 
 
26
27
28
29
30
31
32
33
34
@@ -20,13 +20,15 @@
  unsigned (*hash)(void*, unsigned), unsigned hsize,   int (*cmp)(void*, void*))  { - Node *i; + Node *np;   unsigned h;   h = (*hash)(n->data, hsize); - for (i = htab[h]; i != NULL; i = i->next) - if ((*cmp)(n->data, i->data) == 0) - return i; - if (create == 1) + for (np = htab[h]; np != NULL; np = np->next) + if ((*cmp)(n->data, np->data) == 0) + return np; + if (create == 1) {   htab[h] = addfront(htab[h], n); + return htab[h]; + }   return NULL;  }
Change 1 of 2 Show Entire File test.c Stacked
 
40
41
42
43
44
 
 
45
46
47
 
50
51
52
53
54
55
56
 
40
41
42
 
 
43
44
45
46
47
 
50
51
52
 
53
54
55
@@ -40,8 +40,8 @@
  }   }   - /* - np = hlookup(htab, newnode(newpost(s[0], 0)), 0, + + np = hlookup(htab, newnode(newpost(w[0], 0)), 0,   hash, NHASH, postcmp);     if (np != NULL) { @@ -50,7 +50,6 @@
  }   else   printf("Not found\n"); - */     /* tree test */   /*