DataMuseum.dk

Presents historical artifacts from the history of:

RC9000

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about RC9000

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download
Index: h

⟦ccfb6853e⟧

    Length: 6168 (0x1818)
    Names: »hsearch.3c«

Derivation

└─⟦50656ff4a⟧ Bits:30010538 TX 3.1 Coldstart
    └─⟦bbf173f5c⟧ »0004« 
        └─⟦this⟧ »./usr/man/cat3/hsearch.3c« 

Default Hex Dump

0x0000…0020 0a 0a 0a 5f 08 4f 5f 08 6e 5f 08 6c 5f 08 69 5f 08 6e 5f 08 65 20 5f 08 4d 5f 08 61 5f 08 6e 5f   ┆   _ O_ n_ l_ i_ n_ e _ M_ a_ n_┆
0x0020…0040 08 75 5f 08 61 5f 08 6c 20 20 20 20 20 20 20 20 20 20 20 4c 69 62 72 61 72 79 20 46 75 6e 63 74   ┆ u_ a_ l           Library Funct┆
0x0040…0060 69 6f 6e 73 20 20 20 20 20 20 20 20 20 20 20 20 20 68 73 65 61 72 63 68 28 33 63 29 0a 0a 0a 0a   ┆ions             hsearch(3c)    ┆
0x0060…0080 4e 08 4e 08 4e 08 4e 41 08 41 08 41 08 41 4d 08 4d 08 4d 08 4d 45 08 45 08 45 08 45 0a 20 20 20   ┆N N N NA A A AM M M ME E E E    ┆
0x0080…00a0 20 20 68 73 65 61 72 63 68 2c 20 68 63 72 65 61 74 65 2c 20 68 64 65 73 74 72 6f 79 20 2d 20 6d   ┆  hsearch, hcreate, hdestroy - m┆
0x00a0…00c0 61 6e 61 67 65 20 68 61 73 68 20 73 65 61 72 63 68 20 74 61 62 6c 65 73 0a 0a 53 08 53 08 53 08   ┆anage hash search tables  S S S ┆
0x00c0…00e0 53 59 08 59 08 59 08 59 4e 08 4e 08 4e 08 4e 54 08 54 08 54 08 54 41 08 41 08 41 08 41 58 08 58   ┆SY Y Y YN N N NT T T TA A A AX X┆
0x00e0…0100 08 58 08 58 0a 20 20 20 20 20 23 08 23 08 23 08 23 69 08 69 08 69 08 69 6e 08 6e 08 6e 08 6e 63   ┆ X X      # # # #i i i in n n nc┆
0x0100…0120 08 63 08 63 08 63 6c 08 6c 08 6c 08 6c 75 08 75 08 75 08 75 64 08 64 08 64 08 64 65 08 65 08 65   ┆ c c cl l l lu u u ud d d de e e┆
0x0120…0140 08 65 20 3c 08 3c 08 3c 08 3c 73 08 73 08 73 08 73 65 08 65 08 65 08 65 61 08 61 08 61 08 61 72   ┆ e < < < <s s s se e e ea a a ar┆
0x0140…0160 08 72 08 72 08 72 63 08 63 08 63 08 63 68 08 68 08 68 08 68 2e 08 2e 08 2e 08 2e 68 08 68 08 68   ┆ r r rc c c ch h h h. . . .h h h┆
0x0160…0180 08 68 3e 08 3e 08 3e 08 3e 0a 0a 20 20 20 20 20 45 08 45 08 45 08 45 4e 08 4e 08 4e 08 4e 54 08   ┆ h> > > >       E E E EN N N NT ┆
0x0180…01a0 54 08 54 08 54 52 08 52 08 52 08 52 59 08 59 08 59 08 59 20 2a 08 2a 08 2a 08 2a 68 08 68 08 68   ┆T T TR R R RY Y Y Y * * * *h h h┆
0x01a0…01c0 08 68 73 08 73 08 73 08 73 65 08 65 08 65 08 65 61 08 61 08 61 08 61 72 08 72 08 72 08 72 63 08   ┆ hs s s se e e ea a a ar r r rc ┆
0x01c0…01e0 63 08 63 08 63 68 08 68 08 68 08 68 28 08 28 08 28 08 28 69 08 69 08 69 08 69 74 08 74 08 74 08   ┆c c ch h h h( ( ( (i i i it t t ┆
0x01e0…0200 74 65 08 65 08 65 08 65 6d 08 6d 08 6d 08 6d 2c 08 2c 08 2c 08 2c 20 61 08 61 08 61 08 61 63 08   ┆te e e em m m m, , , , a a a ac ┆
0x0200…0220 63 08 63 08 63 74 08 74 08 74 08 74 69 08 69 08 69 08 69 6f 08 6f 08 6f 08 6f 6e 08 6e 08 6e 08   ┆c c ct t t ti i i io o o on n n ┆
0x0220…0240 6e 29 08 29 08 29 08 29 0a 20 20 20 20 20 45 08 45 08 45 08 45 4e 08 4e 08 4e 08 4e 54 08 54 08   ┆n) ) ) )      E E E EN N N NT T ┆
0x0240…0260 54 08 54 52 08 52 08 52 08 52 59 08 59 08 59 08 59 20 69 08 69 08 69 08 69 74 08 74 08 74 08 74   ┆T TR R R RY Y Y Y i i i it t t t┆
0x0260…0280 65 08 65 08 65 08 65 6d 08 6d 08 6d 08 6d 3b 08 3b 08 3b 08 3b 0a 20 20 20 20 20 41 08 41 08 41   ┆e e e em m m m; ; ; ;      A A A┆
0x0280…02a0 08 41 43 08 43 08 43 08 43 54 08 54 08 54 08 54 49 08 49 08 49 08 49 4f 08 4f 08 4f 08 4f 4e 08   ┆ AC C C CT T T TI I I IO O O ON ┆
0x02a0…02c0 4e 08 4e 08 4e 20 61 08 61 08 61 08 61 63 08 63 08 63 08 63 74 08 74 08 74 08 74 69 08 69 08 69   ┆N N N a a a ac c c ct t t ti i i┆
0x02c0…02e0 08 69 6f 08 6f 08 6f 08 6f 6e 08 6e 08 6e 08 6e 3b 08 3b 08 3b 08 3b 0a 0a 20 20 20 20 20 69 08   ┆ io o o on n n n; ; ; ;       i ┆
0x02e0…0300 69 08 69 08 69 6e 08 6e 08 6e 08 6e 74 08 74 08 74 08 74 20 68 08 68 08 68 08 68 63 08 63 08 63   ┆i i in n n nt t t t h h h hc c c┆
0x0300…0320 08 63 72 08 72 08 72 08 72 65 08 65 08 65 08 65 61 08 61 08 61 08 61 74 08 74 08 74 08 74 65 08   ┆ cr r r re e e ea a a at t t te ┆
0x0320…0340 65 08 65 08 65 28 08 28 08 28 08 28 6e 08 6e 08 6e 08 6e 65 08 65 08 65 08 65 6c 08 6c 08 6c 08   ┆e e e( ( ( (n n n ne e e el l l ┆
0x0340…0360 6c 29 08 29 08 29 08 29 0a 20 20 20 20 20 75 08 75 08 75 08 75 6e 08 6e 08 6e 08 6e 73 08 73 08   ┆l) ) ) )      u u u un n n ns s ┆
0x0360…0380 73 08 73 69 08 69 08 69 08 69 67 08 67 08 67 08 67 6e 08 6e 08 6e 08 6e 65 08 65 08 65 08 65 64   ┆s si i i ig g g gn n n ne e e ed┆
0x0380…03a0 08 64 08 64 08 64 20 6e 08 6e 08 6e 08 6e 65 08 65 08 65 08 65 6c 08 6c 08 6c 08 6c 3b 08 3b 08   ┆ d d d n n n ne e e el l l l; ; ┆
0x03a0…03c0 3b 08 3b 0a 0a 20 20 20 20 20 76 08 76 08 76 08 76 6f 08 6f 08 6f 08 6f 69 08 69 08 69 08 69 64   ┆; ;       v v v vo o o oi i i id┆
0x03c0…03e0 08 64 08 64 08 64 20 68 08 68 08 68 08 68 64 08 64 08 64 08 64 65 08 65 08 65 08 65 73 08 73 08   ┆ d d d h h h hd d d de e e es s ┆
0x03e0…0400 73 08 73 74 08 74 08 74 08 74 72 08 72 08 72 08 72 6f 08 6f 08 6f 08 6f 79 08 79 08 79 08 79 28   ┆s st t t tr r r ro o o oy y y y(┆
0x0400…0420 08 28 08 28 08 28 29 08 29 08 29 08 29 0a 0a 44 08 44 08 44 08 44 45 08 45 08 45 08 45 53 08 53   ┆ ( ( () ) ) )  D D D DE E E ES S┆
0x0420…0440 08 53 08 53 43 08 43 08 43 08 43 52 08 52 08 52 08 52 49 08 49 08 49 08 49 50 08 50 08 50 08 50   ┆ S SC C C CR R R RI I I IP P P P┆
0x0440…0460 54 08 54 08 54 08 54 49 08 49 08 49 08 49 4f 08 4f 08 4f 08 4f 4e 08 4e 08 4e 08 4e 0a 20 20 20   ┆T T T TI I I IO O O ON N N N    ┆
0x0460…0480 20 20 5f 08 68 5f 08 73 5f 08 65 5f 08 61 5f 08 72 5f 08 63 5f 08 68 20 69 73 20 61 20 68 61 73   ┆  _ h_ s_ e_ a_ r_ c_ h is a has┆
0x0480…04a0 68 2d 74 61 62 6c 65 20 73 65 61 72 63 68 20 72 6f 75 74 69 6e 65 2e 20 20 49 74 20 72 65 74 75   ┆h-table search routine.  It retu┆
0x04a0…04c0 72 6e 73 20 61 0a 20 20 20 20 20 70 6f 69 6e 74 65 72 20 69 6e 74 6f 20 61 20 68 61 73 68 20 74   ┆rns a      pointer into a hash t┆
0x04c0…04e0 61 62 6c 65 20 69 6e 64 69 63 61 74 69 6e 67 20 74 68 65 20 6c 6f 63 61 74 69 6f 6e 20 61 74 20   ┆able indicating the location at ┆
0x04e0…0500 77 68 69 63 68 0a 20 20 20 20 20 61 6e 20 65 6e 74 72 79 20 63 61 6e 20 62 65 20 66 6f 75 6e 64   ┆which      an entry can be found┆
0x0500…0520 2e 20 20 5f 08 69 5f 08 74 5f 08 65 5f 08 6d 20 69 73 20 61 20 73 74 72 75 63 74 75 72 65 20 6f   ┆.  _ i_ t_ e_ m is a structure o┆
0x0520…0540 66 20 74 79 70 65 20 45 08 45 08 45 08 45 4e 08 4e 08 4e 08 4e 54 08 54 08 54 08 54 52 08 52 08   ┆f type E E E EN N N NT T T TR R ┆
0x0540…0560 52 08 52 59 08 59 08 59 08 59 0a 20 20 20 20 20 28 64 65 66 69 6e 65 64 20 69 6e 20 74 68 65 20   ┆R RY Y Y Y      (defined in the ┆
0x0560…0580 3c 08 3c 08 3c 08 3c 73 08 73 08 73 08 73 65 08 65 08 65 08 65 61 08 61 08 61 08 61 72 08 72 08   ┆< < < <s s s se e e ea a a ar r ┆
0x0580…05a0 72 08 72 63 08 63 08 63 08 63 68 08 68 08 68 08 68 2e 08 2e 08 2e 08 2e 68 08 68 08 68 08 68 3e   ┆r rc c c ch h h h. . . .h h h h>┆
0x05a0…05c0 08 3e 08 3e 08 3e 20 68 65 61 64 65 72 20 66 69 6c 65 29 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74   ┆ > > > header file) containing t┆
0x05c0…05e0 77 6f 0a 20 20 20 20 20 70 6f 69 6e 74 65 72 73 3a 20 5f 08 69 5f 08 74 5f 08 65 5f 08 6d 2e 5f   ┆wo      pointers: _ i_ t_ e_ m._┆
0x05e0…0600 08 6b 5f 08 65 5f 08 79 20 70 6f 69 6e 74 73 20 74 6f 20 74 68 65 20 63 6f 6d 70 61 72 69 73 6f   ┆ k_ e_ y points to the compariso┆
0x0600…0620 6e 20 6b 65 79 2c 20 61 6e 64 0a 20 20 20 20 20 5f 08 69 5f 08 74 5f 08 65 5f 08 6d 2e 5f 08 64   ┆n key, and      _ i_ t_ e_ m._ d┆
0x0620…0640 5f 08 61 5f 08 74 5f 08 61 20 70 6f 69 6e 74 73 20 74 6f 20 61 6e 79 20 6f 74 68 65 72 20 64 61   ┆_ a_ t_ a points to any other da┆
0x0640…0660 74 61 20 74 6f 20 62 65 20 61 73 73 6f 63 69 61 74 65 64 20 77 69 74 68 0a 20 20 20 20 20 74 68   ┆ta to be associated with      th┆
0x0660…0680 61 74 20 6b 65 79 2e 20 20 28 50 6f 69 6e 74 65 72 73 20 74 6f 20 74 79 70 65 73 20 6f 74 68 65   ┆at key.  (Pointers to types othe┆
0x0680…06a0 72 20 74 68 61 6e 20 76 6f 69 64 20 73 68 6f 75 6c 64 20 62 65 20 63 61 73 74 0a 20 20 20 20 20   ┆r than void should be cast      ┆
0x06a0…06c0 74 6f 20 70 6f 69 6e 74 65 72 2d 74 6f 2d 76 6f 69 64 2e 29 20 5f 08 61 5f 08 63 5f 08 74 5f 08   ┆to pointer-to-void.) _ a_ c_ t_ ┆
0x06c0…06e0 69 5f 08 6f 5f 08 6e 20 69 73 20 61 20 6d 65 6d 62 65 72 20 6f 66 20 61 6e 20 65 6e 75 6d 65 72   ┆i_ o_ n is a member of an enumer┆
0x06e0…0700 61 74 69 6f 6e 0a 20 20 20 20 20 74 79 70 65 20 41 08 41 08 41 08 41 43 08 43 08 43 08 43 54 08   ┆ation      type A A A AC C C CT ┆
0x0700…0720 54 08 54 08 54 49 08 49 08 49 08 49 4f 08 4f 08 4f 08 4f 4e 08 4e 08 4e 08 4e 20 28 64 65 66 69   ┆T T TI I I IO O O ON N N N (defi┆
0x0720…0740 6e 65 64 20 69 6e 20 3c 08 3c 08 3c 08 3c 73 08 73 08 73 08 73 65 08 65 08 65 08 65 61 08 61 08   ┆ned in < < < <s s s se e e ea a ┆
0x0740…0760 61 08 61 72 08 72 08 72 08 72 63 08 63 08 63 08 63 68 08 68 08 68 08 68 2e 08 2e 08 2e 08 2e 68   ┆a ar r r rc c c ch h h h. . . .h┆
0x0760…0780 08 68 08 68 08 68 3e 08 3e 08 3e 08 3e 29 20 69 6e 64 69 63 61 74 69 6e 67 20 74 68 65 20 64 69   ┆ h h h> > > >) indicating the di┆
0x0780…07a0 73 70 6f 73 69 2d 0a 20 20 20 20 20 74 69 6f 6e 20 6f 66 20 74 68 65 20 65 6e 74 72 79 20 69 66   ┆sposi-      tion of the entry if┆
0x07a0…07c0 20 69 74 20 63 61 6e 6e 6f 74 20 62 65 20 66 6f 75 6e 64 20 69 6e 20 74 68 65 20 74 61 62 6c 65   ┆ it cannot be found in the table┆
0x07c0…07e0 2e 20 20 45 08 45 08 45 08 45 4e 08 4e 08 4e 08 4e 54 08 54 08 54 08 54 45 08 45 08 45 08 45 52   ┆.  E E E EN N N NT T T TE E E ER┆
0x07e0…0800 08 52 08 52 08 52 0a 20 20 20 20 20 69 6e 64 69 63 61 74 65 73 20 74 68 61 74 20 74 68 65 20 69   ┆ R R R      indicates that the i┆
0x0800…0820 74 65 6d 20 73 68 6f 75 6c 64 20 62 65 20 69 6e 73 65 72 74 65 64 20 69 6e 20 74 68 65 20 74 61   ┆tem should be inserted in the ta┆
0x0820…0840 62 6c 65 20 61 74 0a 20 20 20 20 20 61 6e 20 61 70 70 72 6f 70 72 69 61 74 65 20 70 6f 69 6e 74   ┆ble at      an appropriate point┆
0x0840…0860 2e 20 20 47 69 76 65 6e 20 61 20 64 75 70 6c 69 63 61 74 65 20 6f 66 20 61 6e 20 65 78 69 73 74   ┆.  Given a duplicate of an exist┆
0x0860…0880 69 6e 67 0a 20 20 20 20 20 69 74 65 6d 2c 20 74 68 65 20 6e 65 77 20 69 74 65 6d 20 69 73 20 6e   ┆ing      item, the new item is n┆
0x0880…08a0 6f 74 20 65 6e 74 65 72 65 64 20 61 6e 64 20 5f 08 68 5f 08 73 5f 08 65 5f 08 61 5f 08 72 5f 08   ┆ot entered and _ h_ s_ e_ a_ r_ ┆
0x08a0…08c0 63 5f 08 68 20 72 65 74 75 72 6e 73 20 61 0a 20 20 20 20 20 70 6f 69 6e 74 65 72 20 74 6f 20 74   ┆c_ h returns a      pointer to t┆
0x08c0…08e0 68 65 20 65 78 69 73 74 69 6e 67 20 69 74 65 6d 2e 20 20 46 08 46 08 46 08 46 49 08 49 08 49 08   ┆he existing item.  F F F FI I I ┆
0x08e0…0900 49 4e 08 4e 08 4e 08 4e 44 08 44 08 44 08 44 20 69 6e 64 69 63 61 74 65 73 20 74 68 61 74 20 6e   ┆IN N N ND D D D indicates that n┆
0x0900…0920 6f 20 65 6e 74 72 79 0a 20 20 20 20 20 73 68 6f 75 6c 64 20 62 65 20 6d 61 64 65 2e 20 20 55 6e   ┆o entry      should be made.  Un┆
0x0920…0940 73 75 63 63 65 73 73 66 75 6c 20 72 65 73 6f 6c 75 74 69 6f 6e 20 69 73 20 69 6e 64 69 63 61 74   ┆successful resolution is indicat┆
0x0940…0960 65 64 20 62 79 20 74 68 65 0a 20 20 20 20 20 72 65 74 75 72 6e 20 6f 66 20 61 20 6e 75 6c 6c 20   ┆ed by the      return of a null ┆
0x0960…0980 70 6f 69 6e 74 65 72 2e 0a 0a 20 20 20 20 20 5f 08 68 5f 08 63 5f 08 72 5f 08 65 5f 08 61 5f 08   ┆pointer.       _ h_ c_ r_ e_ a_ ┆
0x0980…09a0 74 5f 08 65 20 61 6c 6c 6f 63 61 74 65 73 20 73 75 66 66 69 63 69 65 6e 74 20 73 70 61 63 65 20   ┆t_ e allocates sufficient space ┆
0x09a0…09c0 66 6f 72 20 74 68 65 20 74 61 62 6c 65 2c 20 61 6e 64 20 6d 75 73 74 0a 20 20 20 20 20 62 65 20   ┆for the table, and must      be ┆
0x09c0…09e0 63 61 6c 6c 65 64 20 62 65 66 6f 72 65 20 5f 08 68 5f 08 73 5f 08 65 5f 08 61 5f 08 72 5f 08 63   ┆called before _ h_ s_ e_ a_ r_ c┆
0x09e0…0a00 5f 08 68 20 69 73 20 75 73 65 64 2e 20 20 5f 08 6e 5f 08 65 5f 08 6c 20 69 73 20 61 6e 20 65 73   ┆_ h is used.  _ n_ e_ l is an es┆
0x0a00…0a20 74 69 6d 61 74 65 20 6f 66 20 74 68 65 0a 20 20 20 20 20 6d 61 78 69 6d 75 6d 20 6e 75 6d 62 65   ┆timate of the      maximum numbe┆
0x0a20…0a40 72 20 6f 66 20 65 6e 74 72 69 65 73 20 74 68 61 74 20 74 68 65 20 74 61 62 6c 65 20 77 69 6c 6c   ┆r of entries that the table will┆
0x0a40…0a60 20 63 6f 6e 74 61 69 6e 2e 20 20 54 68 69 73 0a 20 20 20 20 20 6e 75 6d 62 65 72 20 6d 61 79 20   ┆ contain.  This      number may ┆
0x0a60…0a80 62 65 20 61 64 6a 75 73 74 65 64 20 75 70 77 61 72 64 20 62 79 20 74 68 65 20 61 6c 67 6f 72 69   ┆be adjusted upward by the algori┆
0x0a80…0aa0 74 68 6d 20 69 6e 20 6f 72 64 65 72 20 74 6f 0a 20 20 20 20 20 6f 62 74 61 69 6e 20 63 65 72 74   ┆thm in order to      obtain cert┆
0x0aa0…0ac0 61 69 6e 20 6d 61 74 68 65 6d 61 74 69 63 61 6c 6c 79 20 66 61 76 6f 72 61 62 6c 65 20 63 69 72   ┆ain mathematically favorable cir┆
0x0ac0…0ae0 63 75 6d 73 74 61 6e 63 65 73 2e 0a 0a 20 20 20 20 20 5f 08 68 5f 08 64 5f 08 65 5f 08 73 5f 08   ┆cumstances.       _ h_ d_ e_ s_ ┆
0x0ae0…0b00 74 5f 08 72 5f 08 6f 5f 08 79 20 64 65 73 74 72 6f 79 73 20 74 68 65 20 73 65 61 72 63 68 20 74   ┆t_ r_ o_ y destroys the search t┆
0x0b00…0b20 61 62 6c 65 2c 20 61 6e 64 20 6d 61 79 20 62 65 20 66 6f 6c 6c 6f 77 65 64 20 62 79 0a 20 20 20   ┆able, and may be followed by    ┆
0x0b20…0b40 20 20 61 6e 6f 74 68 65 72 20 63 61 6c 6c 20 74 6f 20 5f 08 68 5f 08 63 5f 08 72 5f 08 65 5f 08   ┆  another call to _ h_ c_ r_ e_ ┆
0x0b40…0b60 61 5f 08 74 5f 08 65 2e 0a 0a 45 08 45 08 45 08 45 58 08 58 08 58 08 58 41 08 41 08 41 08 41 4d   ┆a_ t_ e.  E E E EX X X XA A A AM┆
0x0b60…0b80 08 4d 08 4d 08 4d 50 08 50 08 50 08 50 4c 08 4c 08 4c 08 4c 45 08 45 08 45 08 45 0a 20 20 20 20   ┆ M M MP P P PL L L LE E E E     ┆
0x0b80…0ba0 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 65 78 61 6d 70 6c 65 20 77 69 6c 6c 20 72 65 61 64   ┆ The following example will read┆
0x0ba0…0bc0 20 69 6e 20 73 74 72 69 6e 67 73 20 66 6f 6c 6c 6f 77 65 64 20 62 79 20 74 77 6f 0a 20 20 20 20   ┆ in strings followed by two     ┆
0x0bc0…0be0 20 6e 75 6d 62 65 72 73 20 61 6e 64 20 73 74 6f 72 65 20 74 68 65 6d 20 69 6e 20 61 20 68 61 73   ┆ numbers and store them in a has┆
0x0be0…0c00 68 20 74 61 62 6c 65 2c 20 64 69 73 63 61 72 64 69 6e 67 20 64 75 70 6c 69 2d 0a 20 20 20 20 20   ┆h table, discarding dupli-      ┆
0x0c00…0c20 63 61 74 65 73 2e 20 20 49 74 20 77 69 6c 6c 20 74 68 65 6e 20 72 65 61 64 20 69 6e 20 73 74 72   ┆cates.  It will then read in str┆
0x0c20…0c40 69 6e 67 73 20 61 6e 64 20 66 69 6e 64 20 74 68 65 20 6d 61 74 63 68 69 6e 67 0a 20 20 20 20 20   ┆ings and find the matching      ┆
0x0c40…0c60 65 6e 74 72 79 20 69 6e 20 74 68 65 20 68 61 73 68 20 74 61 62 6c 65 20 61 6e 64 20 70 72 69 6e   ┆entry in the hash table and prin┆
0x0c60…0c80 74 20 69 74 20 6f 75 74 2e 0a 0a 20 20 20 20 20 20 20 20 20 20 23 69 6e 63 6c 75 64 65 20 3c 73   ┆t it out.            #include <s┆
0x0c80…0ca0 74 64 69 6f 2e 68 3e 0a 20 20 20 20 20 20 20 20 20 20 23 69 6e 63 6c 75 64 65 20 3c 73 65 61 72   ┆tdio.h>           #include <sear┆
0x0ca0…0cc0 63 68 2e 68 3e 0a 0a 20 20 20 20 20 20 20 20 20 20 73 74 72 75 63 74 20 69 6e 66 6f 20 7b 20 20   ┆ch.h>            struct info {  ┆
0x0cc0…0ce0 20 20 20 20 20 2f 2a 20 74 68 69 73 20 69 73 20 74 68 65 20 69 6e 66 6f 20 73 74 6f 72 65 64 20   ┆     /* this is the info stored ┆
0x0ce0…0d00 69 6e 20 74 61 62 6c 65 20 2a 2f 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 6e 74 20 61   ┆in table */                int a┆
0x0d00…0d20 67 65 2c 20 72 6f 6f 6d 3b 20 2f 2a 20 6f 74 68 65 72 20 74 68 61 6e 20 74 68 65 20 6b 65 79 20   ┆ge, room; /* other than the key ┆
0x0d20…0d40 2a 2f 0a 20 20 20 20 20 20 20 20 20 20 7d 3b 0a 0a 20 20 20 20 20 20 20 20 20 20 23 64 65 66 69   ┆*/           };            #defi┆
0x0d40…0d60 6e 65 20 4e 55 4d 5f 45 4d 50 4c 20 20 20 20 35 30 30 30 20 20 20 20 2f 2a 20 23 20 6f 66 20 65   ┆ne NUM_EMPL    5000    /* # of e┆
0x0d60…0d80 6c 65 6d 65 6e 74 73 20 69 6e 20 73 65 61 72 63 68 20 74 61 62 6c 65 20 2a 2f 0a 0a 20 20 20 20   ┆lements in search table */      ┆
0x0d80…0da0 20 20 20 20 20 20 6d 61 69 6e 28 20 29 0a 20 20 20 20 20 20 20 20 20 20 7b 0a 0a 0a 0a 0a 0a 0a   ┆      main( )           {       ┆
0x0da0…0dc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 73 70 61 63 65 20 74 6f 20   ┆                    /* space to ┆
0x0dc0…0de0 73 74 6f 72 65 20 73 74 72 69 6e 67 73 20 2a 2f 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20   ┆store strings */                ┆
0x0de0…0e00 63 68 61 72 20 73 74 72 69 6e 67 5f 73 70 61 63 65 5b 4e 55 4d 5f 45 4d 50 4c 2a 32 30 5d 3b 0a   ┆char string_space[NUM_EMPL*20]; ┆
0x0e00…0e20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 73 70 61 63 65 20 74 6f 20   ┆                    /* space to ┆
0x0e20…0e40 73 74 6f 72 65 20 65 6d 70 6c 6f 79 65 65 20 69 6e 66 6f 20 2a 2f 0a 20 20 20 20 20 20 20 20 20   ┆store employee info */          ┆
0x0e40…0e60 20 20 20 20 20 20 73 74 72 75 63 74 20 69 6e 66 6f 20 69 6e 66 6f 5f 73 70 61 63 65 5b 4e 55 4d   ┆      struct info info_space[NUM┆
0x0e60…0e80 5f 45 4d 50 4c 5d 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 6e   ┆_EMPL];                     /* n┆
0x0e80…0ea0 65 78 74 20 61 76 61 69 6c 20 73 70 61 63 65 20 69 6e 20 73 74 72 69 6e 67 5f 73 70 61 63 65 20   ┆ext avail space in string_space ┆
0x0ea0…0ec0 2a 2f 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 68 61 72 20 2a 73 74 72 5f 70 74 72 20   ┆*/                char *str_ptr ┆
0x0ec0…0ee0 3d 20 73 74 72 69 6e 67 5f 73 70 61 63 65 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20   ┆= string_space;                 ┆
0x0ee0…0f00 20 20 20 20 2f 2a 20 6e 65 78 74 20 61 76 61 69 6c 20 73 70 61 63 65 20 69 6e 20 69 6e 66 6f 5f   ┆    /* next avail space in info_┆
0x0f00…0f20 73 70 61 63 65 20 2a 2f 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 74 72 75 63 74 20 69   ┆space */                struct i┆
0x0f20…0f40 6e 66 6f 20 2a 69 6e 66 6f 5f 70 74 72 20 3d 20 69 6e 66 6f 5f 73 70 61 63 65 3b 0a 20 20 20 20   ┆nfo *info_ptr = info_space;     ┆
0x0f40…0f60 20 20 20 20 20 20 20 20 20 20 20 45 4e 54 52 59 20 69 74 65 6d 2c 20 2a 66 6f 75 6e 64 5f 69 74   ┆           ENTRY item, *found_it┆
0x0f60…0f80 65 6d 2c 20 2a 68 73 65 61 72 63 68 28 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20   ┆em, *hsearch();                 ┆
0x0f80…0fa0 20 20 20 20 2f 2a 20 6e 61 6d 65 20 74 6f 20 6c 6f 6f 6b 20 66 6f 72 20 69 6e 20 74 61 62 6c 65   ┆    /* name to look for in table┆
0x0fa0…0fc0 20 2a 2f 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 68 61 72 20 6e 61 6d 65 5f 74 6f 5f   ┆ */                char name_to_┆
0x0fc0…0fe0 66 69 6e 64 5b 33 30 5d 3b 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 6e 74 20 69 20   ┆find[30];                 int i ┆
0x0fe0…1000 3d 20 30 3b 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 63 72 65 61 74 65 20 74   ┆= 0;                 /* create t┆
0x1000…1020 61 62 6c 65 20 2a 2f 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 76 6f 69 64 29 20 68 63   ┆able */                (void) hc┆
0x1020…1040 72 65 61 74 65 28 4e 55 4d 5f 45 4d 50 4c 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20   ┆reate(NUM_EMPL);                ┆
0x1040…1060 77 68 69 6c 65 20 28 73 63 61 6e 66 28 22 25 73 25 64 25 64 22 2c 20 73 74 72 5f 70 74 72 2c 20   ┆while (scanf("%s%d%d", str_ptr, ┆
0x1060…1080 26 69 6e 66 6f 5f 70 74 72 2d 3e 61 67 65 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20   ┆&info_ptr->age,                 ┆
0x1080…10a0 20 20 20 20 20 20 26 69 6e 66 6f 5f 70 74 72 2d 3e 72 6f 6f 6d 29 20 21 3d 20 45 4f 46 20 26 26   ┆      &info_ptr->room) != EOF &&┆
0x10a0…10c0 20 69 2b 2b 20 3c 20 4e 55 4d 5f 45 4d 50 4c 29 20 7b 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20   ┆ i++ < NUM_EMPL) {              ┆
0x10c0…10e0 20 20 20 20 20 20 20 20 2f 2a 20 70 75 74 20 69 6e 66 6f 20 69 6e 20 73 74 72 75 63 74 75 72 65   ┆        /* put info in structure┆
0x10e0…1100 2c 20 61 6e 64 20 73 74 72 75 63 74 75 72 65 20 69 6e 20 69 74 65 6d 20 2a 2f 0a 20 20 20 20 20   ┆, and structure in item */      ┆
0x1100…1120 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 74 65 6d 2e 6b 65 79 20 3d 20 73 74 72 5f 70 74   ┆               item.key = str_pt┆
0x1120…1140 72 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 74 65 6d 2e 64 61 74 61   ┆r;                     item.data┆
0x1140…1160 20 3d 20 28 76 6f 69 64 20 2a 29 69 6e 66 6f 5f 70 74 72 3b 0a 20 20 20 20 20 20 20 20 20 20 20   ┆ = (void *)info_ptr;            ┆
0x1160…1180 20 20 20 20 20 20 20 20 20 73 74 72 5f 70 74 72 20 2b 3d 20 73 74 72 6c 65 6e 28 73 74 72 5f 70   ┆         str_ptr += strlen(str_p┆
0x1180…11a0 74 72 29 20 2b 20 31 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 6e 66   ┆tr) + 1;                     inf┆
0x11a0…11c0 6f 5f 70 74 72 2b 2b 3b 0a 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a   ┆o_ptr++;                      /*┆
0x11c0…11e0 20 70 75 74 20 69 74 65 6d 20 69 6e 74 6f 20 74 61 62 6c 65 20 2a 2f 0a 20 20 20 20 20 20 20 20   ┆ put item into table */         ┆
0x11e0…1200 20 20 20 20 20 20 20 20 20 20 20 20 28 76 6f 69 64 29 20 68 73 65 61 72 63 68 28 69 74 65 6d 2c   ┆            (void) hsearch(item,┆
0x1200…1220 20 45 4e 54 45 52 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0a 0a 20 20 20 20 20   ┆ ENTER);                }       ┆
0x1220…1240 20 20 20 20 20 20 20 20 20 20 2f 2a 20 61 63 63 65 73 73 20 74 61 62 6c 65 20 2a 2f 0a 20 20 20   ┆          /* access table */    ┆
0x1240…1260 20 20 20 20 20 20 20 20 20 20 20 20 69 74 65 6d 2e 6b 65 79 20 3d 20 6e 61 6d 65 5f 74 6f 5f 66   ┆            item.key = name_to_f┆
0x1260…1280 69 6e 64 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 77 68 69 6c 65 20 28 73 63 61 6e 66   ┆ind;                while (scanf┆
0x1280…12a0 28 22 25 73 22 2c 20 69 74 65 6d 2e 6b 65 79 29 20 21 3d 20 45 4f 46 29 20 7b 0a 20 20 20 20 20   ┆("%s", item.key) != EOF) {      ┆
0x12a0…12c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 28 66 6f 75 6e 64 5f 69 74 65 6d 20 3d 20   ┆              if ((found_item = ┆
0x12c0…12e0 68 73 65 61 72 63 68 28 69 74 65 6d 2c 20 46 49 4e 44 29 29 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a   ┆hsearch(item, FIND)) != NULL) { ┆
0x12e0…1300 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20 69 66 20 69 74 65 6d 20   ┆                     /* if item ┆
0x1300…1320 69 73 20 69 6e 20 74 68 65 20 74 61 62 6c 65 20 2a 2f 0a 20 20 20 20 20 20 20 20 20 20 20 20 20   ┆is in the table */              ┆
0x1320…1340 20 20 20 20 20 20 20 28 76 6f 69 64 29 70 72 69 6e 74 66 28 22 66 6f 75 6e 64 20 25 73 2c 20 61   ┆       (void)printf("found %s, a┆
0x1340…1360 67 65 20 3d 20 25 64 2c 20 72 6f 6f 6d 20 3d 20 25 64 5c 6e 22 2c 0a 20 20 20 20 20 20 20 20 20   ┆ge = %d, room = %d\n",          ┆
0x1360…1380 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 75 6e 64 5f 69 74 65 6d 2d 3e 6b 65 79 2c   ┆                found_item->key,┆
0x1380…13a0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 28 73 74 72 75   ┆                          ((stru┆
0x13a0…13c0 63 74 20 69 6e 66 6f 20 2a 29 66 6f 75 6e 64 5f 69 74 65 6d 2d 3e 64 61 74 61 29 2d 3e 61 67 65   ┆ct info *)found_item->data)->age┆
0x13c0…13e0 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 28 73 74 72   ┆,                          ((str┆
0x13e0…1400 75 63 74 20 69 6e 66 6f 20 2a 29 66 6f 75 6e 64 5f 69 74 65 6d 2d 3e 64 61 74 61 29 2d 3e 72 6f   ┆uct info *)found_item->data)->ro┆
0x1400…1420 6f 6d 29 3b 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 20 65 6c 73 65 20 7b   ┆om);                    } else {┆
0x1420…1440 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 76 6f 69 64 29 70 72 69 6e 74   ┆                     (void)print┆
0x1440…1460 66 28 22 6e 6f 20 73 75 63 68 20 65 6d 70 6c 6f 79 65 65 20 25 73 5c 6e 22 2c 0a 20 20 20 20 20   ┆f("no such employee %s\n",      ┆
0x1460…1480 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6e 61 6d 65 5f 74 6f 5f 66 69 6e 64   ┆                    name_to_find┆
0x1480…14a0 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 20 20 20   ┆)                    }          ┆
0x14a0…14c0 20 20 20 20 20 20 7d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 30 3b   ┆      }                return 0;┆
0x14c0…14e0 0a 20 20 20 20 20 20 20 20 20 20 7d 0a 0a 53 08 53 08 53 08 53 45 08 45 08 45 08 45 45 08 45 08   ┆           }  S S S SE E E EE E ┆
0x14e0…1500 45 08 45 20 41 08 41 08 41 08 41 4c 08 4c 08 4c 08 4c 53 08 53 08 53 08 53 4f 08 4f 08 4f 08 4f   ┆E E A A A AL L L LS S S SO O O O┆
0x1500…1520 0a 20 20 20 20 20 4c 69 62 72 61 72 79 20 46 75 6e 63 74 69 6f 6e 73 20 28 33 29 3a 20 62 73 65   ┆      Library Functions (3): bse┆
0x1520…1540 61 72 63 68 2c 20 6c 73 65 61 72 63 68 2c 20 6d 61 6c 6c 6f 63 2c 20 74 73 65 61 72 63 68 0a 0a   ┆arch, lsearch, malloc, tsearch  ┆
0x1540…1560 44 08 44 08 44 08 44 49 08 49 08 49 08 49 41 08 41 08 41 08 41 47 08 47 08 47 08 47 4e 08 4e 08   ┆D D D DI I I IA A A AG G G GN N ┆
0x1560…1580 4e 08 4e 4f 08 4f 08 4f 08 4f 53 08 53 08 53 08 53 54 08 54 08 54 08 54 49 08 49 08 49 08 49 43   ┆N NO O O OS S S ST T T TI I I IC┆
0x1580…15a0 08 43 08 43 08 43 53 08 53 08 53 08 53 0a 20 20 20 20 20 5f 08 68 5f 08 73 5f 08 65 5f 08 61 5f   ┆ C C CS S S S      _ h_ s_ e_ a_┆
0x15a0…15c0 08 72 5f 08 63 5f 08 68 20 72 65 74 75 72 6e 73 20 61 20 6e 75 6c 6c 20 70 6f 69 6e 74 65 72 20   ┆ r_ c_ h returns a null pointer ┆
0x15c0…15e0 69 66 20 65 69 74 68 65 72 20 74 68 65 20 61 63 74 69 6f 6e 20 69 73 20 46 08 46 08 46 08 46 49   ┆if either the action is F F F FI┆
0x15e0…1600 08 49 08 49 08 49 4e 08 4e 08 4e 08 4e 44 08 44 08 44 08 44 0a 20 20 20 20 20 61 6e 64 20 74 68   ┆ I I IN N N ND D D D      and th┆
0x1600…1620 65 20 69 74 65 6d 20 63 6f 75 6c 64 20 6e 6f 74 20 62 65 20 66 6f 75 6e 64 20 6f 72 20 74 68 65   ┆e item could not be found or the┆
0x1620…1640 20 61 63 74 69 6f 6e 20 69 73 20 45 08 45 08 45 08 45 4e 08 4e 08 4e 08 4e 54 08 54 08 54 08 54   ┆ action is E E E EN N N NT T T T┆
0x1640…1660 45 08 45 08 45 08 45 52 08 52 08 52 08 52 20 61 6e 64 0a 20 20 20 20 20 74 68 65 20 74 61 62 6c   ┆E E E ER R R R and      the tabl┆
0x1660…1680 65 20 69 73 20 66 75 6c 6c 2e 0a 0a 20 20 20 20 20 5f 08 68 5f 08 63 5f 08 72 5f 08 65 5f 08 61   ┆e is full.       _ h_ c_ r_ e_ a┆
0x1680…16a0 5f 08 74 5f 08 65 20 72 65 74 75 72 6e 73 20 7a 65 72 6f 20 69 66 20 69 74 20 63 61 6e 6e 6f 74   ┆_ t_ e returns zero if it cannot┆
0x16a0…16c0 20 61 6c 6c 6f 63 61 74 65 20 73 75 66 66 69 63 69 65 6e 74 20 73 70 61 63 65 0a 20 20 20 20 20   ┆ allocate sufficient space      ┆
0x16c0…16e0 66 6f 72 20 74 68 65 20 74 61 62 6c 65 2e 0a 0a 4e 08 4e 08 4e 08 4e 4f 08 4f 08 4f 08 4f 54 08   ┆for the table.  N N N NO O O OT ┆
0x16e0…1700 54 08 54 08 54 45 08 45 08 45 08 45 53 08 53 08 53 08 53 0a 20 20 20 20 20 5f 08 68 5f 08 73 5f   ┆T T TE E E ES S S S      _ h_ s_┆
0x1700…1720 08 65 5f 08 61 5f 08 72 5f 08 63 5f 08 68 20 61 6e 64 20 5f 08 68 5f 08 63 5f 08 72 5f 08 65 5f   ┆ e_ a_ r_ c_ h and _ h_ c_ r_ e_┆
0x1720…1740 08 61 5f 08 74 5f 08 65 20 75 73 65 20 5f 08 6d 5f 08 61 5f 08 6c 5f 08 6c 5f 08 6f 5f 08 63 28   ┆ a_ t_ e use _ m_ a_ l_ l_ o_ c(┆
0x1740…1760 29 20 74 6f 20 61 6c 6c 6f 63 61 74 65 20 73 70 61 63 65 2e 0a 0a 0a 0a 0a 0a 0a 20 20 20 20 20   ┆) to allocate space.            ┆
0x1760…1780 4f 6e 6c 79 20 6f 6e 65 20 68 61 73 68 20 73 65 61 72 63 68 20 74 61 62 6c 65 20 6d 61 79 20 62   ┆Only one hash search table may b┆
0x1780…17a0 65 20 61 63 74 69 76 65 20 61 74 20 61 6e 79 20 67 69 76 65 6e 20 74 69 6d 65 2e 0a 0a 4d 61 72   ┆e active at any given time.  Mar┆
0x17a0…17c0 63 68 20 31 39 38 39 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20   ┆ch 1989                         ┆
0x17c0…17e0 20 20 20 20 20 54 58 20 50 72 6f 67 72 61 6d 6d 65 72 27 73 20 52 65 66 65 72 65 6e 63 65 0a 0a   ┆     TX Programmer's Reference  ┆
0x17e0…1800 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a   ┆                                ┆
0x1800…1818 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a                           ┆                        ┆