]>
Commit | Line | Data |
---|---|---|
7e5fb030 | 1 | --- hash.c~ Sun Apr 2 23:37:07 2000 |
2 | +++ hash.c Sun Apr 2 23:38:30 2000 | |
3 | @@ -121,7 +121,7 @@ | |
4 | { | |
5 | *last = ptr->next; | |
6 | if (destroy) destroy (ptr->data); | |
7 | - FREE (&ptr); | |
8 | + free (ptr); | |
9 | return; | |
10 | } | |
11 | } | |
12 | @@ -137,15 +137,38 @@ void hash_destroy (HASH **ptr, void (*de | |
13 | HASH *pptr = *ptr; | |
14 | struct hash_elem *elem, *tmp; | |
15 | ||
16 | - for (i = 0 ; i < pptr->nelem; i++) | |
17 | + /* We want to keep the test for the optional destroy argument out | |
18 | + * of the loop to get a faster execution. The price we pay is that | |
19 | + * we then have to have two versions of the loop. | |
20 | + */ | |
21 | +#if 0 | |
22 | + /* Nobody use the destroy argument at the moment, so the destroy | |
23 | + * version of the loop is out-commented until somebody needs it. | |
24 | + */ | |
25 | + if (destroy) | |
26 | { | |
27 | - for (elem = pptr->table[i]; elem; ) | |
28 | + for (i = 0 ; i < pptr->nelem; i++) | |
29 | { | |
30 | - tmp = elem; | |
31 | - elem = elem->next; | |
32 | - if (destroy) | |
33 | + for (elem = pptr->table[i]; elem; ) | |
34 | + { | |
35 | + tmp = elem; | |
36 | + elem = elem->next; | |
37 | destroy (tmp->data); | |
38 | - safe_free ((void **) &tmp); | |
39 | + free (tmp); | |
40 | + } | |
41 | + } | |
42 | + } | |
43 | + else | |
44 | +#endif | |
45 | + { | |
46 | + for (i = 0 ; i < pptr->nelem; i++) | |
47 | + { | |
48 | + for (elem = pptr->table[i]; elem; ) | |
49 | + { | |
50 | + tmp = elem; | |
51 | + elem = elem->next; | |
52 | + free (tmp); | |
53 | + } | |
54 | } | |
55 | } | |
56 | safe_free ((void **) &pptr->table); | |
57 | --- patchlist.c.orig Sat Sep 19 02:29:51 1998 | |
58 | +++ patchlist.c Sat Sep 19 02:54:16 1998 | |
59 | @@ -16,6 +16,8 @@ | |
60 | ||
61 | ||
62 | ||
63 | + printf("Feature patch: hash_destroy 0.95 by Byrial Jensen\n"); | |
64 | + | |
65 | ||
66 | ||
67 | /* DO NOT MODIFY AFTER THIS LINE */ |