00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 #include <stdio.h>
00073 #include <stdlib.h>
00074 #include <string.h>
00075
00076 #include "sfxhash.h"
00077
00078
00079
00080
00081 static
00082 void * s_malloc( SFXHASH * t, int n )
00083 {
00084 return sfmemcap_alloc( &t->mc, n );
00085 }
00086 static
00087 void s_free( SFXHASH * t, void * p )
00088 {
00089 sfmemcap_free( &t->mc, p );
00090 }
00091
00092
00093
00094
00095 void * sfxhash_alloc( SFXHASH * t, unsigned nbytes )
00096 {
00097 return s_malloc( t, nbytes );
00098 }
00099 void sfxhash_free( SFXHASH * t, void * p )
00100 {
00101 s_free( t, p );
00102 }
00103
00104 #ifdef XXXX
00105
00106
00107
00108
00109
00110 #define PRIME_INIT 9791
00111 #define PRIME_SCALE 31
00112 static unsigned sfxhash_data( unsigned char *d, int n )
00113 {
00114 int i;
00115 register unsigned hash = PRIME_INIT;
00116 for(i=0;i<n;i++)
00117 {
00118 hash = hash * PRIME_SCALE + d[i];
00119 }
00120 return hash;
00121 }
00122
00123 #endif
00124
00125
00126
00127
00128
00129 static int isPrime(int num )
00130 {
00131 int i;
00132 for(i=2;i<num;i++)
00133 {
00134 if( (num % i) == 0 ) break;
00135 }
00136 if( i == num ) return 1;
00137 return 0;
00138 }
00139
00140
00141
00142 static int calcNextPrime(int num )
00143 {
00144 while( !isPrime( num ) ) num++;
00145
00146 return num;
00147 }
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 SFXHASH * sfxhash_new( int nrows, int keysize, int datasize, int maxmem,
00176 int anr_flag,
00177 int (*anrfree)(void * key, void * data),
00178 int (*usrfree)(void * key, void * data),
00179 int recycle_flag )
00180 {
00181 int i;
00182 SFXHASH * h;
00183
00184 if( nrows > 0 )
00185 {
00186 nrows = calcNextPrime( nrows );
00187 }
00188 else
00189 {
00190 nrows = -nrows;
00191 }
00192
00193
00194 h = (SFXHASH*) calloc( 1, sizeof(SFXHASH) );
00195 if( !h )
00196 {
00197 return 0;
00198 }
00199
00200
00201 h->sfhashfcn = sfhashfcn_new( nrows );
00202
00203 if( !h->sfhashfcn )
00204 {
00205 return 0;
00206 }
00207
00208 sfmemcap_init( &h->mc, maxmem );
00209
00210
00211 h->table = (SFXHASH_NODE**) s_malloc( h, sizeof(SFXHASH_NODE*) * nrows );
00212 if( !h->table )
00213 {
00214 return 0;
00215 }
00216
00217 for( i=0; i<nrows; i++ )
00218 {
00219 h->table[i] = 0;
00220 }
00221
00222 h->anrfree = anrfree;
00223 h->usrfree = usrfree;
00224 h->keysize = keysize;
00225 h->datasize = datasize;
00226 h->nrows = nrows;
00227 h->crow = 0;
00228 h->cnode = 0;
00229 h->count = 0;
00230 h->ghead = 0;
00231 h->gtail = 0;
00232 h->anr_count= 0;
00233 h->anr_tries= 0;
00234 h->anr_flag = anr_flag;
00235 h->splay = 1;
00236 h->recycle_nodes = recycle_flag;
00237
00238 h->find_success = 0;
00239 h->find_fail = 0;
00240
00241
00242 h->overhead_bytes = h->mc.memused;
00243 h->overhead_blocks = h->mc.nblocks;
00244
00245 return h;
00246 }
00247
00248
00249
00250
00251
00252
00253
00254
00255 void sfxhash_splaymode( SFXHASH * t, int n )
00256 {
00257 t->splay = n;
00258 }
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269 void sfxhash_delete( SFXHASH * h )
00270 {
00271 unsigned i;
00272 SFXHASH_NODE * node, * onode;
00273
00274 if( !h ) return;
00275
00276 if( h->sfhashfcn ) sfhashfcn_free( h->sfhashfcn );
00277
00278 if( h->table )
00279 {
00280 for(i=0;i<h->nrows;i++)
00281 {
00282 for( node=h->table[i]; node; )
00283 {
00284 onode = node;
00285 node = node->next;
00286
00287
00288 if( h->usrfree )
00289 h->usrfree( onode->key, onode->data );
00290
00291 s_free( h,onode );
00292 }
00293 }
00294 s_free( h, h->table );
00295 h->table = 0;
00296 }
00297
00298 free( h );
00299 }
00300
00301
00302
00303
00304
00305
00306
00307 unsigned sfxhash_count( SFXHASH * t )
00308 {
00309 return t->count;
00310 }
00311
00312
00313
00314
00315
00316
00317
00318 unsigned sfxhash_anr_count( SFXHASH * t )
00319 {
00320 return t->anr_count;
00321 }
00322
00323
00324
00325
00326
00327
00328
00329 unsigned sfxhash_find_total( SFXHASH * t )
00330 {
00331 return t->find_success + t->find_fail;
00332 }
00333
00334
00335
00336
00337
00338
00339
00340 unsigned sfxhash_find_fail( SFXHASH * t )
00341 {
00342 return t->find_fail;
00343 }
00344
00345
00346
00347
00348
00349
00350
00351 unsigned sfxhash_find_success( SFXHASH * t )
00352 {
00353 return t->find_success;
00354 }
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365 unsigned sfxhash_overhead_bytes( SFXHASH * t )
00366 {
00367 return t->overhead_bytes;
00368 }
00369
00370
00371
00372
00373
00374
00375
00376 unsigned sfxhash_overhead_blocks( SFXHASH * t )
00377 {
00378 return t->overhead_blocks;
00379 }
00380
00381
00382
00383
00384 static
00385 void sfxhash_save_free_node( SFXHASH *t, SFXHASH_NODE * hnode )
00386 {
00387
00388 if( t->fhead )
00389 {
00390 hnode->gprev = 0;
00391 hnode->gnext = t->fhead;
00392 t->fhead->gprev = hnode;
00393 t->fhead = hnode;
00394
00395 }
00396 else
00397 {
00398 hnode->gprev = 0;
00399 hnode->gnext = 0;
00400 t->fhead = hnode;
00401 t->ftail = hnode;
00402 }
00403 }
00404 static
00405 SFXHASH_NODE * sfxhash_get_free_node( SFXHASH *t )
00406 {
00407 SFXHASH_NODE * node = t->fhead;
00408
00409
00410 if( t->fhead )
00411 {
00412 t->fhead = t->fhead->gnext;
00413 if( t->fhead )
00414 t->fhead->gprev = 0;
00415
00416 if( t->ftail == node )
00417 t->ftail = 0;
00418 }
00419
00420 return node;
00421 }
00422
00423 static
00424 void sfxhash_glink_node( SFXHASH *t, SFXHASH_NODE * hnode )
00425 {
00426
00427 if( t->ghead )
00428 {
00429 hnode->gprev = 0;
00430 hnode->gnext = t->ghead;
00431 t->ghead->gprev = hnode;
00432 t->ghead = hnode;
00433
00434 }
00435 else
00436 {
00437 hnode->gprev = 0;
00438 hnode->gnext = 0;
00439 t->ghead = hnode;
00440 t->gtail = hnode;
00441 }
00442 }
00443
00444 static
00445 void sfxhash_gunlink_node( SFXHASH *t, SFXHASH_NODE * hnode )
00446 {
00447
00448 if( t->ghead == hnode )
00449 {
00450 t->ghead = t->ghead->gnext;
00451 if( t->ghead )
00452 t->ghead->gprev = 0;
00453 }
00454
00455 if( hnode->gprev ) hnode->gprev->gnext = hnode->gnext;
00456 if( hnode->gnext ) hnode->gnext->gprev = hnode->gprev;
00457
00458 if( t->gtail == hnode )
00459 t->gtail = hnode->gprev;
00460 }
00461
00462 void sfxhash_gmovetofront( SFXHASH *t, SFXHASH_NODE * hnode )
00463 {
00464 if( hnode != t->ghead )
00465 {
00466 sfxhash_gunlink_node( t, hnode );
00467 sfxhash_glink_node( t, hnode );
00468 }
00469 }
00470
00471
00472
00473
00474 static
00475 void sfxhash_link_node( SFXHASH * t, SFXHASH_NODE * hnode )
00476 {
00477
00478 if( t->table[hnode->rindex] )
00479 {
00480 hnode->prev = 0;
00481 hnode->next=t->table[hnode->rindex];
00482 t->table[hnode->rindex]->prev = hnode;
00483 t->table[hnode->rindex] = hnode;
00484 }
00485 else
00486 {
00487 hnode->prev=0;
00488 hnode->next=0;
00489 t->table[hnode->rindex] = hnode;
00490 }
00491 }
00492
00493 static
00494 void sfxhash_unlink_node( SFXHASH * t, SFXHASH_NODE * hnode )
00495 {
00496 if( hnode->prev )
00497 {
00498 hnode->prev->next = hnode->next;
00499 if( hnode->next )
00500 hnode->next->prev = hnode->prev;
00501 }
00502 else if( t->table[hnode->rindex] )
00503 {
00504 t->table[hnode->rindex] = t->table[hnode->rindex]->next;
00505 if( t->table[hnode->rindex] )
00506 t->table[hnode->rindex]->prev = 0;
00507 }
00508 }
00509
00510
00511
00512
00513 static void movetofront( SFXHASH *t, SFXHASH_NODE * n )
00514 {
00515
00516 if( t->table[n->rindex] != n )
00517 {
00518
00519 sfxhash_unlink_node( t, n );
00520
00521
00522 sfxhash_link_node( t, n );
00523 }
00524
00525
00526 sfxhash_gmovetofront( t, n );
00527 }
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539 static
00540 SFXHASH_NODE * sfxhash_newnode( SFXHASH * t )
00541 {
00542 SFXHASH_NODE * hnode;
00543
00544
00545 hnode = sfxhash_get_free_node( t );
00546
00547
00548 if( ! hnode )
00549 {
00550 hnode = (SFXHASH_NODE*)s_malloc( t, sizeof(SFXHASH_NODE) +
00551 t->keysize + t->datasize );
00552 }
00553
00554
00555
00556
00557
00558
00559 if( !hnode && t->anr_flag && t->gtail )
00560 {
00561
00562 for(hnode = t->gtail; hnode; hnode = hnode->gprev )
00563 {
00564 if( t->anrfree )
00565 {
00566 t->anr_tries++;
00567
00568
00569 if( t->anrfree( hnode->key, hnode->data ) )
00570 {
00571
00572 continue;
00573 }
00574
00575
00576 }
00577
00578 sfxhash_gunlink_node( t, hnode );
00579 sfxhash_unlink_node( t, hnode );
00580 t->count--;
00581 t->anr_count++;
00582 break;
00583 }
00584 }
00585
00586
00587
00588 return hnode;
00589 }
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599 static
00600 SFXHASH_NODE * sfxhash_find_node_row( SFXHASH * t, void * key, int * rindex )
00601 {
00602 unsigned hashkey;
00603 int index;
00604 SFXHASH_NODE *hnode;
00605
00606 hashkey = t->sfhashfcn->hash_fcn( t->sfhashfcn,
00607 (unsigned char*)key,
00608 t->keysize );
00609
00610
00611
00612
00613
00614 index = hashkey % t->nrows;
00615
00616 *rindex = index;
00617
00618 for( hnode=t->table[index]; hnode; hnode=hnode->next )
00619 {
00620 if( !t->sfhashfcn->keycmp_fcn(hnode->key,key,t->keysize) )
00621 {
00622 if( t->splay > 0 )
00623 movetofront(t,hnode);
00624
00625 t->find_success++;
00626 return hnode;
00627 }
00628 }
00629
00630 t->find_fail++;
00631 return NULL;
00632 }
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654 int sfxhash_add( SFXHASH * t, void * key, void * data )
00655 {
00656 int index;
00657 SFXHASH_NODE * hnode;
00658
00659
00660 hnode = sfxhash_find_node_row( t, key, &index );
00661
00662 if( hnode )
00663 {
00664 t->cnode = hnode;
00665
00666 return SFXHASH_INTABLE;
00667 }
00668
00669
00670
00671
00672 hnode = sfxhash_newnode( t );
00673 if( !hnode )
00674 {
00675 return SFXHASH_NOMEM;
00676 }
00677
00678
00679 hnode->key = (char*)hnode + sizeof(SFXHASH_NODE);
00680
00681
00682 memcpy(hnode->key,key,t->keysize);
00683
00684
00685 hnode->rindex = index;
00686
00687
00688 if( t->datasize )
00689 {
00690
00691 hnode->data= (char*)hnode + sizeof(SFXHASH_NODE) + t->keysize;
00692
00693 if(data)
00694 {
00695 memcpy(hnode->data,data,t->datasize);
00696 }
00697 }
00698 else
00699 {
00700 hnode->data = data;
00701 }
00702
00703
00704 sfxhash_link_node ( t, hnode );
00705
00706
00707 sfxhash_glink_node( t, hnode );
00708
00709
00710 t->count++;
00711
00712 return SFXHASH_OK;
00713 }
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733 SFXHASH_NODE * sfxhash_get_node( SFXHASH * t, void * key )
00734 {
00735 int index;
00736 SFXHASH_NODE * hnode;
00737
00738
00739 hnode = sfxhash_find_node_row( t, key, &index );
00740
00741 if( hnode )
00742 {
00743 t->cnode = hnode;
00744
00745 return hnode;
00746 }
00747
00748
00749
00750
00751 hnode = sfxhash_newnode( t );
00752 if( !hnode )
00753 {
00754 return NULL;
00755 }
00756
00757
00758 hnode->key = (char*)hnode + sizeof(SFXHASH_NODE);
00759
00760
00761 memcpy(hnode->key,key,t->keysize);
00762
00763
00764 hnode->rindex = index;
00765
00766
00767 if( t->datasize )
00768 {
00769
00770 hnode->data= (char*)hnode + sizeof(SFXHASH_NODE) + t->keysize;
00771 }
00772 else
00773 {
00774 hnode->data = NULL;
00775 }
00776
00777
00778 sfxhash_link_node ( t, hnode );
00779
00780
00781 sfxhash_glink_node( t, hnode );
00782
00783
00784 t->count++;
00785
00786 return hnode;
00787 }
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800 SFXHASH_NODE * sfxhash_find_node( SFXHASH * t, void * key)
00801 {
00802 int rindex;
00803
00804 return sfxhash_find_node_row( t, key, &rindex );
00805 }
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817 void * sfxhash_find( SFXHASH * t, void * key)
00818 {
00819 SFXHASH_NODE * hnode;
00820 int rindex;
00821
00822 hnode = sfxhash_find_node_row( t, key, &rindex );
00823
00824 if( hnode ) return hnode->data;
00825
00826 return NULL;
00827 }
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837 SFXHASH_NODE *sfxhash_ghead( SFXHASH * t )
00838 {
00839 if(t)
00840 {
00841 return t->ghead;
00842 }
00843
00844 return NULL;
00845 }
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855 SFXHASH_NODE *sfxhash_gnext( SFXHASH_NODE *n )
00856 {
00857 if(n)
00858 {
00859 return n->gnext;
00860 }
00861
00862 return NULL;
00863 }
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875 void * sfxhash_mru( SFXHASH * t )
00876 {
00877 SFXHASH_NODE * hnode;
00878
00879 hnode = sfxhash_ghead(t);
00880
00881 if( hnode )
00882 return hnode->data;
00883
00884 return NULL;
00885 }
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896 void * sfxhash_lru( SFXHASH * t )
00897 {
00898 SFXHASH_NODE * hnode;
00899
00900 hnode = t->gtail;
00901
00902 if( hnode ) return hnode->data;
00903
00904 return NULL;
00905 }
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916 SFXHASH_NODE * sfxhash_mru_node( SFXHASH * t )
00917 {
00918 SFXHASH_NODE * hnode;
00919
00920 hnode = sfxhash_ghead(t);
00921
00922 if( hnode )
00923 return hnode;
00924
00925 return NULL;
00926 }
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937 SFXHASH_NODE * sfxhash_lru_node( SFXHASH * t )
00938 {
00939 SFXHASH_NODE * hnode;
00940
00941 hnode = t->gtail;
00942
00943 if( hnode ) return hnode;
00944
00945 return NULL;
00946 }
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958 unsigned sfxhash_maxdepth( SFXHASH * t )
00959 {
00960 unsigned i;
00961 unsigned max_depth = 0;
00962
00963 SFXHASH_NODE * hnode;
00964
00965 for( i=0; i<t->nrows; i++ )
00966 {
00967 unsigned cur_depth = 0;
00968
00969 for(hnode = t->table[i]; hnode != NULL; hnode = hnode->next)
00970 {
00971 cur_depth++;
00972 }
00973
00974 if(cur_depth > max_depth)
00975 max_depth = cur_depth;
00976 }
00977
00978 return max_depth;
00979 }
00980
00981
00982
00983
00984 int sfxhash_free_node( SFXHASH * t, SFXHASH_NODE * hnode)
00985 {
00986 sfxhash_unlink_node( t, hnode );
00987
00988 sfxhash_gunlink_node( t, hnode );
00989
00990 t->count--;
00991
00992 if( t->usrfree )
00993 {
00994 t->usrfree( hnode->key, hnode->data );
00995 }
00996
00997 if( t->recycle_nodes )
00998 {
00999 sfxhash_save_free_node( t, hnode );
01000 }
01001 else
01002 {
01003 s_free( t, hnode );
01004 }
01005
01006 return SFXHASH_OK;
01007 }
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019 int sfxhash_remove( SFXHASH * t, void * key)
01020 {
01021 SFXHASH_NODE * hnode;
01022 unsigned hashkey, index;
01023
01024 hashkey = t->sfhashfcn->hash_fcn( t->sfhashfcn,
01025 (unsigned char*)key,
01026 t->keysize );
01027
01028 index = hashkey % t->nrows;
01029
01030 hnode = t->table[index];
01031
01032 for( hnode=t->table[index]; hnode; hnode=hnode->next )
01033 {
01034 if( !t->sfhashfcn->keycmp_fcn(hnode->key,key,t->keysize) )
01035 {
01036 return sfxhash_free_node( t, hnode );
01037 }
01038 }
01039
01040 return SFXHASH_ERR;
01041 }
01042
01043
01044
01045
01046 static
01047 void sfxhash_next( SFXHASH * t )
01048 {
01049 if( !t->cnode )
01050 return ;
01051
01052
01053 t->cnode = t->cnode->next;
01054 if( t->cnode )
01055 {
01056 return;
01057 }
01058
01059
01060
01061 for( t->crow++; t->crow < t->nrows; t->crow++ )
01062 {
01063 t->cnode = t->table[ t->crow ];
01064 if( t->cnode )
01065 {
01066 return;
01067 }
01068 }
01069 }
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079 SFXHASH_NODE * sfxhash_findfirst( SFXHASH * t )
01080 {
01081 SFXHASH_NODE * n;
01082
01083
01084 for( t->crow=0; t->crow < t->nrows; t->crow++ )
01085 {
01086
01087 t->cnode = t->table[ t->crow ];
01088 if( t->cnode )
01089 {
01090 n = t->cnode;
01091 sfxhash_next( t );
01092 return n;
01093 }
01094 }
01095
01096 return NULL;
01097 }
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108 SFXHASH_NODE * sfxhash_findnext( SFXHASH * t )
01109 {
01110 SFXHASH_NODE * n;
01111
01112 n = t->cnode;
01113 if( !n )
01114 {
01115 return NULL;
01116 }
01117
01118
01119
01120
01121 sfxhash_next( t );
01122
01123 return n;
01124 }
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135 int sfxhash_set_keyops( SFXHASH *h ,
01136 unsigned (*hash_fcn)( SFHASHFCN * p,
01137 unsigned char *d,
01138 int n),
01139 int (*keycmp_fcn)( const void *s1,
01140 const void *s2,
01141 size_t n))
01142 {
01143 if(h && hash_fcn && keycmp_fcn)
01144 {
01145 return sfhashfcn_set_keyops(h->sfhashfcn, hash_fcn, keycmp_fcn);
01146 }
01147
01148 return -1;
01149 }
01150
01151
01152
01153
01154
01155
01156
01157 #ifdef SFXHASH_MAIN
01158
01159
01160
01161
01162
01163 int usrfree( void * key, void * data )
01164 {
01165
01166
01167 return 0;
01168 }
01169
01170
01171
01172
01173
01174
01175
01176
01177 int anrfree( void * key, void * data )
01178 {
01179 static int bx = 0;
01180
01181
01182
01183
01184
01185
01186 if( !bx ) usrfree( key, data );
01187
01188 return bx;
01189 }
01190
01191
01192
01193
01194 int main ( int argc, char ** argv )
01195 {
01196 int i;
01197 SFXHASH * t;
01198 SFXHASH_NODE * n;
01199 char strkey[256], strdata[256], * p;
01200 int num = 100;
01201 int mem = 0;
01202
01203 memset(strkey,0,20);
01204 memset(strdata,0,20);
01205
01206 if( argc > 1 )
01207 {
01208 num = atoi(argv[1]);
01209 }
01210
01211 if( argc > 2 )
01212 {
01213 mem = atoi(argv[2]);
01214 }
01215
01216
01217 t = sfxhash_new( 100,
01218 20,
01219 20,
01220 mem,
01221 1,
01222 anrfree,
01223 usrfree,
01224 1);
01225 if(!t)
01226 {
01227 printf("Low Memory!\n");
01228 exit(0);
01229 }
01230
01231 for(i=0;i<num;i++)
01232 {
01233 sprintf(strkey, "KeyWord%5.5d",i+1);
01234 sprintf(strdata,"KeyWord%5.5d",i+1);
01235
01236 sfxhash_add( t, strkey , strdata );
01237 }
01238
01239
01240 printf("\n** FIND KEY TEST\n");
01241 for(i=0;i<num;i++)
01242 {
01243 sprintf(strkey,"KeyWord%5.5d",i+1);
01244
01245 p = (char*) sfxhash_find( t, strkey );
01246
01247 if(p)printf("Hash-key=%*s, data=%*s\n", strlen(strkey),strkey, strlen(strkey), p );
01248 }
01249
01250
01251 printf("\n...******\n");
01252 sfmemcap_showmem(&t->mc);
01253 printf("...******\n");
01254
01255
01256 printf("\n...FINDFIRST / FINDNEXT TEST\n");
01257 for( n = sfxhash_findfirst(t);
01258 n != 0;
01259 n = sfxhash_findnext(t) )
01260 {
01261 printf("hash-findfirst/next: n=%x, key=%s, data=%s\n", n, n->key, n->data );
01262
01263
01264
01265
01266 if( sfxhash_remove(t,n->key) )
01267 {
01268 printf("...ERROR: Could not remove the key node!\n");
01269 }
01270 else
01271 {
01272 printf("...key node removed\n");
01273 }
01274 }
01275
01276 printf("...Auto-Node-Recovery: %d recycle attempts, %d completions.\n",t->anr_tries,t->anr_count);
01277
01278
01279 printf("...sfxhash_delete\n");
01280
01281 sfxhash_delete( t );
01282
01283 printf("\nnormal pgm finish\n\n");
01284
01285 return 0;
01286 }
01287 #endif
01288
01289