home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / unix / volume20 / memlin.tok < prev    next >
SHell self-extracting ARchive  |  1989-10-27  |  15.8 KB

open in: MacOS 8.1     |     Win98     |     DOS

view JSON data     |     view as text

This file was processed as: SHell self-extracting ARchive (archive/shar).

You can browse this item here: memlin.tok

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Newsgroup Content (archive/news) magic Supported
100% dexvert SHell self-extracting ARchive (archive/shar) magic Supported
100% dexvert Internet Message Format (text/imf) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file news, ASCII text default
100% checkBytes Printable ASCII default
100% dexmagic PrintFox/Pagefox WEAK default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/329 Shell Archive Format default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime message/news default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 50 61 74 68 3a 20 77 75 | 61 72 63 68 69 76 65 21 |Path: wu|archive!|
|00000010| 75 77 6d 2e 65 64 75 21 | 67 65 6d 2e 6d 70 73 2e |uwm.edu!|gem.mps.|
|00000020| 6f 68 69 6f 2d 73 74 61 | 74 65 2e 65 64 75 21 73 |ohio-sta|te.edu!s|
|00000030| 61 6d 73 75 6e 67 21 78 | 61 6e 74 68 21 62 62 6e |amsung!x|anth!bbn|
|00000040| 2e 63 6f 6d 21 72 73 61 | 6c 7a 0a 46 72 6f 6d 3a |.com!rsa|lz.From:|
|00000050| 20 72 73 61 6c 7a 40 75 | 75 6e 65 74 2e 75 75 2e | rsalz@u|unet.uu.|
|00000060| 6e 65 74 20 28 52 69 63 | 68 20 53 61 6c 7a 29 0a |net (Ric|h Salz).|
|00000070| 4e 65 77 73 67 72 6f 75 | 70 73 3a 20 63 6f 6d 70 |Newsgrou|ps: comp|
|00000080| 2e 73 6f 75 72 63 65 73 | 2e 75 6e 69 78 0a 53 75 |.sources|.unix.Su|
|00000090| 62 6a 65 63 74 3a 20 76 | 32 30 69 30 37 37 3a 20 |bject: v|20i077: |
|000000a0| 20 41 20 70 61 63 6b 61 | 67 65 20 74 6f 20 72 65 | A packa|ge to re|
|000000b0| 6d 6f 76 65 20 63 6f 6d | 6d 6f 6e 20 6c 69 6e 74 |move com|mon lint|
|000000c0| 2f 6d 61 6c 6c 6f 63 20 | 63 6f 6d 70 6c 61 69 6e |/malloc |complain|
|000000d0| 74 73 0a 4d 65 73 73 61 | 67 65 2d 49 44 3a 20 3c |ts.Messa|ge-ID: <|
|000000e0| 32 30 39 33 40 70 61 70 | 61 79 61 2e 62 62 6e 2e |2093@pap|aya.bbn.|
|000000f0| 63 6f 6d 3e 0a 44 61 74 | 65 3a 20 32 37 20 4f 63 |com>.Dat|e: 27 Oc|
|00000100| 74 20 38 39 20 31 37 3a | 31 32 3a 31 36 20 47 4d |t 89 17:|12:16 GM|
|00000110| 54 0a 4c 69 6e 65 73 3a | 20 35 34 38 0a 41 70 70 |T.Lines:| 548.App|
|00000120| 72 6f 76 65 64 3a 20 72 | 73 61 6c 7a 40 75 75 6e |roved: r|salz@uun|
|00000130| 65 74 2e 55 55 2e 4e 45 | 54 0a 0a 53 75 62 6d 69 |et.UU.NE|T..Submi|
|00000140| 74 74 65 64 2d 62 79 3a | 20 42 6f 62 20 4c 65 77 |tted-by:| Bob Lew|
|00000150| 69 73 20 3c 75 75 6e 65 | 74 21 74 65 73 73 69 21 |is <uune|t!tessi!|
|00000160| 62 6f 62 6c 3e 0a 50 6f | 73 74 69 6e 67 2d 6e 75 |bobl>.Po|sting-nu|
|00000170| 6d 62 65 72 3a 20 56 6f | 6c 75 6d 65 20 32 30 2c |mber: Vo|lume 20,|
|00000180| 20 49 73 73 75 65 20 37 | 37 0a 41 72 63 68 69 76 | Issue 7|7.Archiv|
|00000190| 65 2d 6e 61 6d 65 3a 20 | 6d 65 6d 6c 69 6e 74 6f |e-name: |memlinto|
|000001a0| 6b 0a 0a 5b 20 20 56 61 | 72 69 6f 75 73 20 74 6f |k..[ Va|rious to|
|000001b0| 6f 6c 73 20 61 6e 64 20 | 74 72 69 63 6b 73 20 66 |ols and |tricks f|
|000001c0| 6f 72 20 64 6f 69 6e 67 | 20 74 68 69 73 20 61 62 |or doing| this ab|
|000001d0| 6f 75 6e 64 3b 20 6d 69 | 67 68 74 20 61 73 20 77 |ound; mi|ght as w|
|000001e0| 65 6c 6c 20 67 65 74 20 | 6f 6e 65 0a 20 20 20 69 |ell get |one. i|
|000001f0| 6e 20 74 68 65 20 61 72 | 63 68 69 76 65 73 2e 20 |n the ar|chives. |
|00000200| 20 50 6c 65 61 73 65 20 | 64 6f 6e 27 74 20 73 75 | Please |don't su|
|00000210| 62 6d 69 74 20 61 6e 79 | 20 6f 74 68 65 72 73 20 |bmit any| others |
|00000220| 75 6e 6c 65 73 73 20 74 | 68 65 79 27 72 65 0a 20 |unless t|hey're. |
|00000230| 20 20 73 69 67 6e 69 66 | 69 63 61 6e 74 6c 79 20 | signif|icantly |
|00000240| 62 65 74 74 65 72 20 6f | 72 20 64 69 66 66 65 72 |better o|r differ|
|00000250| 65 6e 74 2e 20 20 2f 72 | 24 20 20 5d 0a 0a 22 6d |ent. /r|$ ].."m|
|00000260| 65 6d 6c 69 6e 74 6f 6b | 2e 68 22 20 69 73 20 61 |emlintok|.h" is a|
|00000270| 20 68 65 61 64 65 72 20 | 66 69 6c 65 20 74 68 61 | header |file tha|
|00000280| 74 20 63 61 6e 20 62 65 | 20 75 73 65 64 20 74 6f |t can be| used to|
|00000290| 20 70 6f 6c 69 74 65 6c | 79 20 73 68 75 74 20 6c | politel|y shut l|
|000002a0| 69 6e 74 28 31 29 0a 75 | 70 20 61 62 6f 75 74 20 |int(1).u|p about |
|000002b0| 63 61 73 74 69 6e 67 20 | 72 65 73 75 6c 74 73 20 |casting |results |
|000002c0| 6f 66 20 6d 65 6d 6f 72 | 79 20 61 6c 6c 6f 63 61 |of memor|y alloca|
|000002d0| 74 69 6f 6e 20 66 75 6e | 63 74 69 6f 6e 73 20 6d |tion fun|ctions m|
|000002e0| 61 6c 6c 6f 63 28 33 29 | 2c 0a 72 65 61 6c 6c 6f |alloc(3)|,.reallo|
|000002f0| 63 28 33 29 2c 20 61 6e | 64 20 63 61 6c 6c 6f 63 |c(3), an|d calloc|
|00000300| 28 33 29 2e 20 20 49 74 | 20 61 6c 73 6f 20 73 74 |(3). It| also st|
|00000310| 6f 70 73 20 63 6f 6d 70 | 6c 61 69 6e 74 73 20 61 |ops comp|laints a|
|00000320| 62 6f 75 74 20 74 68 65 | 20 61 72 67 75 6d 65 6e |bout the| argumen|
|00000330| 74 20 6f 66 0a 66 72 65 | 65 28 33 29 2e 0a 0a 23 |t of.fre|e(3)...#|
|00000340| 21 20 2f 62 69 6e 2f 73 | 68 0a 23 20 54 68 69 73 |! /bin/s|h.# This|
|00000350| 20 69 73 20 61 20 73 68 | 65 6c 6c 20 61 72 63 68 | is a sh|ell arch|
|00000360| 69 76 65 2e 20 20 52 65 | 6d 6f 76 65 20 61 6e 79 |ive. Re|move any|
|00000370| 74 68 69 6e 67 20 62 65 | 66 6f 72 65 20 74 68 69 |thing be|fore thi|
|00000380| 73 20 6c 69 6e 65 2c 20 | 74 68 65 6e 20 75 6e 70 |s line, |then unp|
|00000390| 61 63 6b 0a 23 20 69 74 | 20 62 79 20 73 61 76 69 |ack.# it| by savi|
|000003a0| 6e 67 20 69 74 20 69 6e | 74 6f 20 61 20 66 69 6c |ng it in|to a fil|
|000003b0| 65 20 61 6e 64 20 74 79 | 70 69 6e 67 20 22 73 68 |e and ty|ping "sh|
|000003c0| 20 66 69 6c 65 22 2e 20 | 20 54 6f 20 6f 76 65 72 | file". | To over|
|000003d0| 77 72 69 74 65 20 65 78 | 69 73 74 69 6e 67 0a 23 |write ex|isting.#|
|000003e0| 20 66 69 6c 65 73 2c 20 | 74 79 70 65 20 22 73 68 | files, |type "sh|
|000003f0| 20 66 69 6c 65 20 2d 63 | 22 2e 20 20 59 6f 75 20 | file -c|". You |
|00000400| 63 61 6e 20 61 6c 73 6f | 20 66 65 65 64 20 74 68 |can also| feed th|
|00000410| 69 73 20 61 73 20 73 74 | 61 6e 64 61 72 64 20 69 |is as st|andard i|
|00000420| 6e 70 75 74 20 76 69 61 | 0a 23 20 75 6e 73 68 61 |nput via|.# unsha|
|00000430| 72 2c 20 6f 72 20 62 79 | 20 74 79 70 69 6e 67 20 |r, or by| typing |
|00000440| 22 73 68 20 3c 66 69 6c | 65 22 2c 20 65 2e 67 2e |"sh <fil|e", e.g.|
|00000450| 2e 20 20 49 66 20 74 68 | 69 73 20 61 72 63 68 69 |. If th|is archi|
|00000460| 76 65 20 69 73 20 63 6f | 6d 70 6c 65 74 65 2c 20 |ve is co|mplete, |
|00000470| 79 6f 75 0a 23 20 77 69 | 6c 6c 20 73 65 65 20 74 |you.# wi|ll see t|
|00000480| 68 65 20 66 6f 6c 6c 6f | 77 69 6e 67 20 6d 65 73 |he follo|wing mes|
|00000490| 73 61 67 65 20 61 74 20 | 74 68 65 20 65 6e 64 3a |sage at |the end:|
|000004a0| 0a 23 09 09 22 45 6e 64 | 20 6f 66 20 73 68 65 6c |.#.."End| of shel|
|000004b0| 6c 20 61 72 63 68 69 76 | 65 2e 22 0a 23 20 43 6f |l archiv|e.".# Co|
|000004c0| 6e 74 65 6e 74 73 3a 20 | 20 52 45 41 44 4d 45 20 |ntents: | README |
|000004d0| 4d 61 6b 65 66 69 6c 65 | 20 67 6f 6f 64 20 6d 65 |Makefile| good me|
|000004e0| 6d 6c 69 6e 74 6f 6b 2e | 33 20 6d 65 6d 6c 69 6e |mlintok.|3 memlin|
|000004f0| 74 6f 6b 2e 68 20 74 5f | 6d 65 6d 6c 69 6e 74 6f |tok.h t_|memlinto|
|00000500| 6b 2e 63 0a 50 41 54 48 | 3d 2f 62 69 6e 3a 2f 75 |k.c.PATH|=/bin:/u|
|00000510| 73 72 2f 62 69 6e 3a 2f | 75 73 72 2f 75 63 62 20 |sr/bin:/|usr/ucb |
|00000520| 3b 20 65 78 70 6f 72 74 | 20 50 41 54 48 0a 69 66 |; export| PATH.if|
|00000530| 20 74 65 73 74 20 2d 66 | 20 52 45 41 44 4d 45 20 | test -f| README |
|00000540| 2d 61 20 22 24 7b 31 7d | 22 20 21 3d 20 22 2d 63 |-a "${1}|" != "-c|
|00000550| 22 20 3b 20 74 68 65 6e | 20 0a 20 20 65 63 68 6f |" ; then| . echo|
|00000560| 20 73 68 61 72 3a 20 57 | 69 6c 6c 20 6e 6f 74 20 | shar: W|ill not |
|00000570| 6f 76 65 72 2d 77 72 69 | 74 65 20 65 78 69 73 74 |over-wri|te exist|
|00000580| 69 6e 67 20 66 69 6c 65 | 20 5c 22 52 45 41 44 4d |ing file| \"READM|
|00000590| 45 5c 22 0a 65 6c 73 65 | 0a 65 63 68 6f 20 73 68 |E\".else|.echo sh|
|000005a0| 61 72 3a 20 45 78 74 72 | 61 63 74 69 6e 67 20 5c |ar: Extr|acting \|
|000005b0| 22 52 45 41 44 4d 45 5c | 22 20 5c 28 31 37 34 37 |"README\|" \(1747|
|000005c0| 20 63 68 61 72 61 63 74 | 65 72 73 5c 29 0a 73 65 | charact|ers\).se|
|000005d0| 64 20 22 73 2f 5e 58 2f | 2f 22 20 3e 52 45 41 44 |d "s/^X/|/" >READ|
|000005e0| 4d 45 20 3c 3c 27 45 4e | 44 5f 4f 46 5f 52 45 41 |ME <<'EN|D_OF_REA|
|000005f0| 44 4d 45 27 0a 58 22 6d | 65 6d 6c 69 6e 74 6f 6b |DME'.X"m|emlintok|
|00000600| 2e 68 22 20 69 73 20 61 | 20 68 65 61 64 65 72 20 |.h" is a| header |
|00000610| 66 69 6c 65 20 74 68 61 | 74 20 63 61 6e 20 62 65 |file tha|t can be|
|00000620| 20 75 73 65 64 20 74 6f | 20 70 6f 6c 69 74 65 6c | used to| politel|
|00000630| 79 20 73 68 75 74 20 6c | 69 6e 74 28 31 29 20 75 |y shut l|int(1) u|
|00000640| 70 0a 58 61 62 6f 75 74 | 20 63 61 73 74 69 6e 67 |p.Xabout| casting|
|00000650| 20 72 65 73 75 6c 74 73 | 20 6f 66 20 6d 65 6d 6f | results| of memo|
|00000660| 72 79 20 61 6c 6c 6f 63 | 61 74 69 6f 6e 20 66 75 |ry alloc|ation fu|
|00000670| 6e 63 74 69 6f 6e 73 20 | 6d 61 6c 6c 6f 63 28 33 |nctions |malloc(3|
|00000680| 29 2c 20 72 65 61 6c 6c | 6f 63 28 33 29 2c 0a 58 |), reall|oc(3),.X|
|00000690| 61 6e 64 20 63 61 6c 6c | 6f 63 28 33 29 2e 20 20 |and call|oc(3). |
|000006a0| 49 74 20 61 6c 73 6f 20 | 73 74 6f 70 73 20 63 6f |It also |stops co|
|000006b0| 6d 70 6c 61 69 6e 74 73 | 20 61 62 6f 75 74 20 74 |mplaints| about t|
|000006c0| 68 65 20 61 72 67 75 6d | 65 6e 74 20 6f 66 20 66 |he argum|ent of f|
|000006d0| 72 65 65 28 33 29 2e 0a | 58 0a 58 43 4f 4e 54 45 |ree(3)..|X.XCONTE|
|000006e0| 4e 54 53 0a 58 2d 2d 2d | 2d 2d 2d 2d 2d 0a 58 46 |NTS.X---|-----.XF|
|000006f0| 69 6c 65 73 20 69 6e 20 | 74 68 69 73 20 64 69 73 |iles in |this dis|
|00000700| 74 72 69 62 75 74 69 6f | 6e 20 61 72 65 3a 0a 58 |tributio|n are:.X|
|00000710| 0a 58 52 45 41 44 4d 45 | 09 09 09 79 6f 75 27 72 |.XREADME|...you'r|
|00000720| 65 20 72 65 61 64 69 6e | 67 20 69 74 0a 58 4d 61 |e readin|g it.XMa|
|00000730| 6b 65 66 69 6c 65 09 09 | 68 61 73 20 73 65 76 65 |kefile..|has seve|
|00000740| 72 61 6c 20 75 73 65 66 | 75 6c 20 74 61 72 67 65 |ral usef|ul targe|
|00000750| 74 73 2c 20 69 6e 63 6c | 75 64 69 6e 67 20 22 69 |ts, incl|uding "i|
|00000760| 6e 73 74 61 6c 6c 22 20 | 61 6e 64 20 22 74 65 73 |nstall" |and "tes|
|00000770| 74 22 0a 58 67 6f 6f 64 | 09 09 09 67 6f 6f 64 20 |t".Xgood|...good |
|00000780| 72 65 73 75 6c 74 73 20 | 66 6f 72 20 22 6d 61 6b |results |for "mak|
|00000790| 65 20 74 65 73 74 22 0a | 58 6d 65 6d 6c 69 6e 74 |e test".|Xmemlint|
|000007a0| 6f 6b 2e 33 09 09 6d 61 | 6e 20 70 61 67 65 0a 58 |ok.3..ma|n page.X|
|000007b0| 6d 65 6d 6c 69 6e 74 6f | 6b 2e 68 09 09 74 68 65 |memlinto|k.h..the|
|000007c0| 20 68 65 61 64 65 72 20 | 66 69 6c 65 20 69 74 73 | header |file its|
|000007d0| 65 6c 66 0a 58 74 5f 6d | 65 6d 6c 69 6e 74 6f 6b |elf.Xt_m|emlintok|
|000007e0| 2e 63 09 61 20 74 65 73 | 74 2f 64 65 6d 6f 20 70 |.c.a tes|t/demo p|
|000007f0| 72 6f 67 72 61 6d 0a 58 | 0a 58 44 49 53 43 55 53 |rogram.X|.XDISCUS|
|00000800| 53 49 4f 4e 0a 58 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |SION.X--|--------|
|00000810| 0a 58 4f 6e 65 20 63 6f | 6d 6d 6f 6e 20 77 61 79 |.XOne co|mmon way|
|00000820| 20 6f 66 20 69 67 6e 6f | 72 69 6e 67 20 6c 69 6e | of igno|ring lin|
|00000830| 74 20 65 72 72 6f 72 73 | 20 69 73 20 74 6f 20 64 |t errors| is to d|
|00000840| 6f 20 73 6f 6d 65 74 68 | 69 6e 67 20 6c 69 6b 65 |o someth|ing like|
|00000850| 3a 0a 58 0a 58 09 23 69 | 66 64 65 66 20 6c 69 6e |:.X.X.#i|fdef lin|
|00000860| 74 0a 58 09 23 64 65 66 | 69 6e 65 20 6d 61 6c 6c |t.X.#def|ine mall|
|00000870| 6f 63 28 61 72 67 29 20 | 4e 55 4c 4c 0a 58 09 23 |oc(arg) |NULL.X.#|
|00000880| 65 6e 64 69 66 0a 58 0a | 58 54 68 65 20 74 72 6f |endif.X.|XThe tro|
|00000890| 75 62 6c 65 20 77 69 74 | 68 20 64 6f 69 6e 67 20 |uble wit|h doing |
|000008a0| 74 68 69 6e 67 73 20 74 | 68 69 73 20 77 61 79 20 |things t|his way |
|000008b0| 69 73 20 74 68 61 74 20 | 6c 69 6e 74 20 77 69 6c |is that |lint wil|
|000008c0| 6c 20 6e 6f 74 20 74 68 | 65 6e 20 62 65 20 61 62 |l not th|en be ab|
|000008d0| 6c 65 20 74 6f 0a 58 63 | 68 65 63 6b 20 6d 61 6c |le to.Xc|heck mal|
|000008e0| 6c 6f 63 27 73 20 61 72 | 67 75 6d 65 6e 74 2c 20 |loc's ar|gument, |
|000008f0| 73 6f 20 79 6f 75 20 63 | 6f 75 6c 64 20 67 65 74 |so you c|ould get|
|00000900| 20 61 77 61 79 20 77 69 | 74 68 20 73 6f 6d 65 74 | away wi|th somet|
|00000910| 68 69 6e 67 20 6c 69 6b | 65 3a 0a 58 0a 58 09 63 |hing lik|e:.X.X.c|
|00000920| 68 61 72 20 2a 70 3b 0a | 58 09 63 68 61 72 20 2a |har *p;.|X.char *|
|00000930| 71 3b 0a 58 09 2e 2e 2e | 0a 58 09 70 20 3d 20 6d |q;.X....|.X.p = m|
|00000940| 61 6c 6c 6f 63 28 71 29 | 3b 0a 58 0a 58 54 68 65 |alloc(q)|;.X.XThe|
|00000950| 20 6d 61 63 72 6f 73 20 | 68 65 72 65 20 61 72 65 | macros |here are|
|00000960| 20 61 20 62 69 74 20 6d | 6f 72 65 20 73 6f 70 68 | a bit m|ore soph|
|00000970| 69 73 74 69 63 61 74 65 | 64 2c 20 73 6f 20 74 68 |isticate|d, so th|
|00000980| 61 74 20 74 68 65 20 6d | 65 6d 6f 72 79 20 66 75 |at the m|emory fu|
|00000990| 6e 63 74 69 6f 6e 73 0a | 58 67 65 74 20 69 6e 76 |nctions.|Xget inv|
|000009a0| 6f 6b 65 64 20 69 6e 20 | 61 20 73 79 6e 74 61 63 |oked in |a syntac|
|000009b0| 74 69 63 61 6c 6c 79 20 | 63 6f 72 72 65 63 74 20 |tically |correct |
|000009c0| 61 6e 64 20 70 72 6f 70 | 65 72 6c 79 2d 74 79 70 |and prop|erly-typ|
|000009d0| 65 64 20 28 61 6c 74 68 | 6f 75 67 68 0a 58 73 65 |ed (alth|ough.Xse|
|000009e0| 6d 61 6e 74 69 63 61 6c | 6c 79 20 69 6e 63 6f 72 |mantical|ly incor|
|000009f0| 72 65 63 74 29 20 66 61 | 73 68 69 6f 6e 20 61 6e |rect) fa|shion an|
|00000a00| 64 20 74 68 65 20 61 72 | 67 75 6d 65 6e 74 73 20 |d the ar|guments |
|00000a10| 67 65 74 20 63 68 65 63 | 6b 65 64 0a 58 69 6e 64 |get chec|ked.Xind|
|00000a20| 65 70 65 6e 64 65 6e 74 | 6c 79 2e 20 20 54 68 65 |ependent|ly. The|
|00000a30| 20 6d 61 6e 20 70 61 67 | 65 20 64 65 73 63 72 69 | man pag|e descri|
|00000a40| 62 65 73 20 74 68 65 69 | 72 20 75 73 65 2e 0a 58 |bes thei|r use..X|
|00000a50| 0a 58 54 68 65 20 66 69 | 6c 65 20 61 6c 73 6f 20 |.XThe fi|le also |
|00000a60| 69 6e 63 6c 75 64 65 73 | 20 61 20 6d 61 63 72 6f |includes| a macro|
|00000a70| 20 4d 52 5f 41 4c 4c 4f | 43 5f 4c 49 4e 54 4f 4b | MR_ALLO|C_LINTOK|
|00000a80| 20 74 68 61 74 20 69 73 | 20 73 69 6d 70 6c 79 20 | that is| simply |
|00000a90| 61 20 63 6f 6d 70 61 63 | 74 20 66 6f 72 6d 0a 58 |a compac|t form.X|
|00000aa0| 6f 66 20 74 68 65 20 63 | 6f 6d 6d 6f 6e 6c 79 2d |of the c|ommonly-|
|00000ab0| 6f 63 63 75 72 72 69 6e | 67 20 63 6f 64 65 20 74 |occurrin|g code t|
|00000ac0| 6f 20 61 6c 6c 6f 63 61 | 74 65 20 6d 65 6d 6f 72 |o alloca|te memor|
|00000ad0| 79 20 69 66 20 61 20 28 | 74 79 70 69 63 61 6c 6c |y if a (|typicall|
|00000ae0| 79 20 73 74 61 74 69 63 | 29 0a 58 70 6f 69 6e 74 |y static|).Xpoint|
|00000af0| 65 72 20 69 73 20 4e 55 | 4c 4c 20 61 6e 64 20 74 |er is NU|LL and t|
|00000b00| 6f 20 72 65 61 6c 6c 6f | 63 61 74 65 20 69 74 20 |o reallo|cate it |
|00000b10| 69 66 20 74 68 65 20 70 | 6f 69 6e 74 65 72 20 69 |if the p|ointer i|
|00000b20| 73 6e 27 74 20 4e 55 4c | 4c 2e 0a 58 0a 58 54 68 |sn't NUL|L..X.XTh|
|00000b30| 65 72 65 20 61 72 65 20 | 61 6c 73 6f 20 6d 61 63 |ere are |also mac|
|00000b40| 72 6f 73 20 74 6f 20 64 | 6f 20 73 6f 6d 65 20 70 |ros to d|o some p|
|00000b50| 72 69 6d 69 74 69 76 65 | 20 65 78 63 65 70 74 69 |rimitive| excepti|
|00000b60| 6f 6e 20 68 61 6e 64 6c | 69 6e 67 20 6f 66 20 74 |on handl|ing of t|
|00000b70| 68 65 20 6d 65 6d 6f 72 | 79 0a 58 61 6c 6c 6f 63 |he memor|y.Xalloc|
|00000b80| 61 74 69 6f 6e 20 66 75 | 6e 63 74 69 6f 6e 2e 20 |ation fu|nction. |
|00000b90| 20 53 65 65 20 74 68 65 | 20 6d 61 6e 20 70 61 67 | See the| man pag|
|00000ba0| 65 20 66 6f 72 20 6d 6f | 72 65 20 6f 6e 20 74 68 |e for mo|re on th|
|00000bb0| 65 73 65 2e 0a 58 0a 58 | 41 73 20 49 20 64 65 76 |ese..X.X|As I dev|
|00000bc0| 65 6c 6f 70 65 64 20 69 | 74 20 77 69 74 68 20 6d |eloped i|t with m|
|00000bd0| 79 20 6f 77 6e 20 72 65 | 73 6f 75 72 63 65 73 2c |y own re|sources,|
|00000be0| 20 49 27 6d 20 72 65 6c | 65 61 73 69 6e 67 20 74 | I'm rel|easing t|
|00000bf0| 68 69 73 20 63 6f 64 65 | 20 74 6f 20 74 68 65 0a |his code| to the.|
|00000c00| 58 70 75 62 6c 69 63 20 | 64 6f 6d 61 69 6e 2e 20 |Xpublic |domain. |
|00000c10| 20 49 20 68 65 72 65 62 | 79 20 64 65 6e 79 20 61 | I hereb|y deny a|
|00000c20| 6e 79 20 72 65 73 70 6f | 6e 73 69 62 69 6c 69 74 |ny respo|nsibilit|
|00000c30| 79 20 66 6f 72 20 69 74 | 73 20 75 73 65 20 6f 72 |y for it|s use or|
|00000c40| 20 61 6e 79 20 64 61 6d | 61 67 65 73 0a 58 72 65 | any dam|ages.Xre|
|00000c50| 73 75 6c 74 69 6e 67 20 | 66 72 6f 6d 20 73 61 6d |sulting |from sam|
|00000c60| 65 2e 0a 58 0a 58 4e 65 | 76 65 72 74 68 65 6c 65 |e..X.XNe|verthele|
|00000c70| 73 73 2c 20 69 66 20 61 | 6e 79 6f 6e 65 20 68 61 |ss, if a|nyone ha|
|00000c80| 73 20 61 6e 79 20 70 72 | 6f 62 6c 65 6d 73 20 77 |s any pr|oblems w|
|00000c90| 69 74 68 20 69 74 2c 20 | 71 75 65 73 74 69 6f 6e |ith it, |question|
|00000ca0| 73 20 61 62 6f 75 74 20 | 69 74 2c 20 6f 72 0a 58 |s about |it, or.X|
|00000cb0| 69 6d 70 72 6f 76 65 6d | 65 6e 74 73 20 74 6f 20 |improvem|ents to |
|00000cc0| 69 74 2c 20 70 6c 65 61 | 73 65 20 6c 65 74 20 6d |it, plea|se let m|
|00000cd0| 65 20 6b 6e 6f 77 2e 0a | 58 0a 58 09 2d 20 42 6f |e know..|X.X.- Bo|
|00000ce0| 62 20 4c 65 77 69 73 0a | 58 09 20 20 62 6f 62 6c |b Lewis.|X. bobl|
|00000cf0| 40 74 65 73 73 69 2e 75 | 75 63 70 0a 45 4e 44 5f |@tessi.u|ucp.END_|
|00000d00| 4f 46 5f 52 45 41 44 4d | 45 0a 69 66 20 74 65 73 |OF_READM|E.if tes|
|00000d10| 74 20 31 37 34 37 20 2d | 6e 65 20 60 77 63 20 2d |t 1747 -|ne `wc -|
|00000d20| 63 20 3c 52 45 41 44 4d | 45 60 3b 20 74 68 65 6e |c <READM|E`; then|
|00000d30| 0a 20 20 20 20 65 63 68 | 6f 20 73 68 61 72 3a 20 |. ech|o shar: |
|00000d40| 5c 22 52 45 41 44 4d 45 | 5c 22 20 75 6e 70 61 63 |\"README|\" unpac|
|00000d50| 6b 65 64 20 77 69 74 68 | 20 77 72 6f 6e 67 20 73 |ked with| wrong s|
|00000d60| 69 7a 65 21 0a 66 69 0a | 23 20 65 6e 64 20 6f 66 |ize!.fi.|# end of|
|00000d70| 20 6f 76 65 72 77 72 69 | 74 69 6e 67 20 63 68 65 | overwri|ting che|
|00000d80| 63 6b 0a 66 69 0a 69 66 | 20 74 65 73 74 20 2d 66 |ck.fi.if| test -f|
|00000d90| 20 4d 61 6b 65 66 69 6c | 65 20 2d 61 20 22 24 7b | Makefil|e -a "${|
|00000da0| 31 7d 22 20 21 3d 20 22 | 2d 63 22 20 3b 20 74 68 |1}" != "|-c" ; th|
|00000db0| 65 6e 20 0a 20 20 65 63 | 68 6f 20 73 68 61 72 3a |en . ec|ho shar:|
|00000dc0| 20 57 69 6c 6c 20 6e 6f | 74 20 6f 76 65 72 2d 77 | Will no|t over-w|
|00000dd0| 72 69 74 65 20 65 78 69 | 73 74 69 6e 67 20 66 69 |rite exi|sting fi|
|00000de0| 6c 65 20 5c 22 4d 61 6b | 65 66 69 6c 65 5c 22 0a |le \"Mak|efile\".|
|00000df0| 65 6c 73 65 0a 65 63 68 | 6f 20 73 68 61 72 3a 20 |else.ech|o shar: |
|00000e00| 45 78 74 72 61 63 74 69 | 6e 67 20 5c 22 4d 61 6b |Extracti|ng \"Mak|
|00000e10| 65 66 69 6c 65 5c 22 20 | 5c 28 39 35 31 20 63 68 |efile\" |\(951 ch|
|00000e20| 61 72 61 63 74 65 72 73 | 5c 29 0a 73 65 64 20 22 |aracters|\).sed "|
|00000e30| 73 2f 5e 58 2f 2f 22 20 | 3e 4d 61 6b 65 66 69 6c |s/^X//" |>Makefil|
|00000e40| 65 20 3c 3c 27 45 4e 44 | 5f 4f 46 5f 4d 61 6b 65 |e <<'END|_OF_Make|
|00000e50| 66 69 6c 65 27 0a 58 23 | 20 24 48 65 61 64 65 72 |file'.X#| $Header|
|00000e60| 3a 20 4d 61 6b 65 66 69 | 6c 65 2c 76 20 31 2e 34 |: Makefi|le,v 1.4|
|00000e70| 20 38 39 2f 30 35 2f 30 | 32 20 31 35 3a 30 36 3a | 89/05/0|2 15:06:|
|00000e80| 34 38 20 62 6f 62 6c 20 | 45 78 70 20 24 0a 58 0a |48 bobl |Exp $.X.|
|00000e90| 58 64 65 66 61 75 6c 74 | 3a 20 6e 65 77 0a 58 0a |Xdefault|: new.X.|
|00000ea0| 58 23 0a 58 23 09 54 68 | 69 73 20 69 73 20 77 68 |X#.X#.Th|is is wh|
|00000eb0| 65 72 65 20 79 6f 75 20 | 77 61 6e 74 20 74 68 65 |ere you |want the|
|00000ec0| 20 68 65 61 64 65 72 20 | 74 6f 20 67 6f 2e 20 20 | header |to go. |
|00000ed0| 49 74 20 6d 69 67 68 74 | 20 62 65 20 61 64 76 69 |It might| be advi|
|00000ee0| 73 61 62 6c 65 20 74 6f | 0a 58 23 09 70 75 74 20 |sable to|.X#.put |
|00000ef0| 69 74 20 69 6e 20 73 6f | 6d 65 20 6c 6f 63 61 6c |it in so|me local|
|00000f00| 20 64 69 72 65 63 74 6f | 72 79 20 72 61 74 68 65 | directo|ry rathe|
|00000f10| 72 20 74 68 61 6e 20 74 | 68 69 73 20 64 65 66 61 |r than t|his defa|
|00000f20| 75 6c 74 20 6f 6e 65 2e | 2e 2e 0a 58 23 0a 58 48 |ult one.|...X#.XH|
|00000f30| 44 52 5f 44 45 53 54 20 | 3d 20 2f 75 73 72 2f 69 |DR_DEST |= /usr/i|
|00000f40| 6e 63 6c 75 64 65 0a 58 | 0a 58 23 0a 58 23 09 54 |nclude.X|.X#.X#.T|
|00000f50| 68 65 20 6d 61 6e 20 70 | 61 67 65 20 67 6f 65 73 |he man p|age goes|
|00000f60| 20 68 65 72 65 2e 20 20 | 41 67 61 69 6e 2c 20 79 | here. |Again, y|
|00000f70| 6f 75 20 6d 61 79 20 68 | 61 76 65 20 73 6f 6d 65 |ou may h|ave some|
|00000f80| 20 6c 6f 63 61 6c 20 70 | 6c 61 63 65 20 74 6f 20 | local p|lace to |
|00000f90| 70 75 74 20 69 74 2e 0a | 58 23 0a 58 4d 41 4e 5f |put it..|X#.XMAN_|
|00000fa0| 44 45 53 54 20 3d 20 2f | 75 73 72 2f 6d 61 6e 2f |DEST = /|usr/man/|
|00000fb0| 6d 61 6e 33 0a 58 0a 58 | 46 49 4c 45 53 20 3d 20 |man3.X.X|FILES = |
|00000fc0| 5c 0a 58 09 52 45 41 44 | 4d 45 20 5c 0a 58 09 4d |\.X.READ|ME \.X.M|
|00000fd0| 61 6b 65 66 69 6c 65 20 | 5c 0a 58 09 67 6f 6f 64 |akefile |\.X.good|
|00000fe0| 20 5c 0a 58 09 6d 65 6d | 6c 69 6e 74 6f 6b 2e 33 | \.X.mem|lintok.3|
|00000ff0| 20 5c 0a 58 09 6d 65 6d | 6c 69 6e 74 6f 6b 2e 68 | \.X.mem|lintok.h|
|00001000| 20 5c 0a 58 09 74 5f 6d | 65 6d 6c 69 6e 74 6f 6b | \.X.t_m|emlintok|
|00001010| 2e 63 0a 58 0a 58 63 6c | 65 61 6e 3a 0a 58 09 72 |.c.X.Xcl|ean:.X.r|
|00001020| 6d 20 2d 66 20 74 5f 6d | 65 6d 6c 69 6e 74 6f 6b |m -f t_m|emlintok|
|00001030| 20 6e 65 77 20 63 6f 72 | 65 20 61 2e 6f 75 74 20 | new cor|e a.out |
|00001040| 2a 2e 6f 20 6d 65 6d 6c | 69 6e 74 6f 6b 2e 73 68 |*.o meml|intok.sh|
|00001050| 61 72 0a 58 0a 58 6e 65 | 77 3a 09 74 5f 6d 65 6d |ar.X.Xne|w:.t_mem|
|00001060| 6c 69 6e 74 6f 6b 0a 58 | 09 74 5f 6d 65 6d 6c 69 |lintok.X|.t_memli|
|00001070| 6e 74 6f 6b 20 3e 6e 65 | 77 0a 58 0a 58 74 5f 6d |ntok >ne|w.X.Xt_m|
|00001080| 65 6d 6c 69 6e 74 6f 6b | 3a 09 74 5f 6d 65 6d 6c |emlintok|:.t_meml|
|00001090| 69 6e 74 6f 6b 2e 63 20 | 6d 65 6d 6c 69 6e 74 6f |intok.c |memlinto|
|000010a0| 6b 2e 68 0a 58 09 63 63 | 20 74 5f 6d 65 6d 6c 69 |k.h.X.cc| t_memli|
|000010b0| 6e 74 6f 6b 2e 63 20 2d | 6f 20 74 5f 6d 65 6d 6c |ntok.c -|o t_meml|
|000010c0| 69 6e 74 6f 6b 0a 58 0a | 58 74 65 73 74 3a 09 6e |intok.X.|Xtest:.n|
|000010d0| 65 77 20 74 5f 6d 65 6d | 6c 69 6e 74 6f 6b 0a 58 |ew t_mem|lintok.X|
|000010e0| 09 40 65 63 68 6f 20 22 | 23 20 63 6f 6d 70 61 72 |.@echo "|# compar|
|000010f0| 69 6e 67 20 6e 65 77 20 | 72 65 73 75 6c 74 73 20 |ing new |results |
|00001100| 77 69 74 68 20 6b 6e 6f | 77 6e 20 67 6f 6f 64 20 |with kno|wn good |
|00001110| 6f 6e 65 73 3a 22 0a 58 | 09 64 69 66 66 20 6e 65 |ones:".X|.diff ne|
|00001120| 77 20 67 6f 6f 64 0a 58 | 09 40 65 63 68 6f 20 22 |w good.X|.@echo "|
|00001130| 23 20 73 68 6f 75 6c 64 | 20 62 65 20 6e 6f 20 6c |# should| be no l|
|00001140| 69 6e 74 20 65 72 72 6f | 72 73 3a 22 0a 58 09 6c |int erro|rs:".X.l|
|00001150| 69 6e 74 20 2d 62 61 63 | 68 78 20 74 5f 6d 65 6d |int -bac|hx t_mem|
|00001160| 6c 69 6e 74 6f 6b 2e 63 | 0a 58 0a 58 75 70 64 61 |lintok.c|.X.Xupda|
|00001170| 74 65 3a 09 6e 65 77 0a | 58 09 6d 76 20 2d 66 20 |te:.new.|X.mv -f |
|00001180| 6e 65 77 20 67 6f 6f 64 | 0a 58 0a 58 73 68 61 72 |new good|.X.Xshar|
|00001190| 3a 20 6d 65 6d 6c 69 6e | 74 6f 6b 2e 73 68 61 72 |: memlin|tok.shar|
|000011a0| 0a 58 0a 58 6d 65 6d 6c | 69 6e 74 6f 6b 2e 73 68 |.X.Xmeml|intok.sh|
|000011b0| 61 72 3a 20 24 28 46 49 | 4c 45 53 29 0a 58 09 73 |ar: $(FI|LES).X.s|
|000011c0| 68 61 72 20 24 28 46 49 | 4c 45 53 29 20 3e 6d 65 |har $(FI|LES) >me|
|000011d0| 6d 6c 69 6e 74 6f 6b 2e | 73 68 61 72 0a 58 0a 58 |mlintok.|shar.X.X|
|000011e0| 69 6e 73 74 61 6c 6c 3a | 20 6d 65 6d 6c 69 6e 74 |install:| memlint|
|000011f0| 6f 6b 2e 68 20 6d 65 6d | 6c 69 6e 74 6f 6b 2e 33 |ok.h mem|lintok.3|
|00001200| 0a 58 09 63 70 20 6d 65 | 6d 6c 69 6e 74 6f 6b 2e |.X.cp me|mlintok.|
|00001210| 68 20 24 28 48 44 52 5f | 44 45 53 54 29 0a 58 09 |h $(HDR_|DEST).X.|
|00001220| 63 70 20 6d 65 6d 6c 69 | 6e 74 6f 6b 2e 33 20 24 |cp memli|ntok.3 $|
|00001230| 28 4d 41 4e 5f 44 45 53 | 54 29 0a 58 0a 58 09 0a |(MAN_DES|T).X.X..|
|00001240| 45 4e 44 5f 4f 46 5f 4d | 61 6b 65 66 69 6c 65 0a |END_OF_M|akefile.|
|00001250| 69 66 20 74 65 73 74 20 | 39 35 31 20 2d 6e 65 20 |if test |951 -ne |
|00001260| 60 77 63 20 2d 63 20 3c | 4d 61 6b 65 66 69 6c 65 |`wc -c <|Makefile|
|00001270| 60 3b 20 74 68 65 6e 0a | 20 20 20 20 65 63 68 6f |`; then.| echo|
|00001280| 20 73 68 61 72 3a 20 5c | 22 4d 61 6b 65 66 69 6c | shar: \|"Makefil|
|00001290| 65 5c 22 20 75 6e 70 61 | 63 6b 65 64 20 77 69 74 |e\" unpa|cked wit|
|000012a0| 68 20 77 72 6f 6e 67 20 | 73 69 7a 65 21 0a 66 69 |h wrong |size!.fi|
|000012b0| 0a 23 20 65 6e 64 20 6f | 66 20 6f 76 65 72 77 72 |.# end o|f overwr|
|000012c0| 69 74 69 6e 67 20 63 68 | 65 63 6b 0a 66 69 0a 69 |iting ch|eck.fi.i|
|000012d0| 66 20 74 65 73 74 20 2d | 66 20 67 6f 6f 64 20 2d |f test -|f good -|
|000012e0| 61 20 22 24 7b 31 7d 22 | 20 21 3d 20 22 2d 63 22 |a "${1}"| != "-c"|
|000012f0| 20 3b 20 74 68 65 6e 20 | 0a 20 20 65 63 68 6f 20 | ; then |. echo |
|00001300| 73 68 61 72 3a 20 57 69 | 6c 6c 20 6e 6f 74 20 6f |shar: Wi|ll not o|
|00001310| 76 65 72 2d 77 72 69 74 | 65 20 65 78 69 73 74 69 |ver-writ|e existi|
|00001320| 6e 67 20 66 69 6c 65 20 | 5c 22 67 6f 6f 64 5c 22 |ng file |\"good\"|
|00001330| 0a 65 6c 73 65 0a 65 63 | 68 6f 20 73 68 61 72 3a |.else.ec|ho shar:|
|00001340| 20 45 78 74 72 61 63 74 | 69 6e 67 20 5c 22 67 6f | Extract|ing \"go|
|00001350| 6f 64 5c 22 20 5c 28 32 | 34 34 20 63 68 61 72 61 |od\" \(2|44 chara|
|00001360| 63 74 65 72 73 5c 29 0a | 73 65 64 20 22 73 2f 5e |cters\).|sed "s/^|
|00001370| 58 2f 2f 22 20 3e 67 6f | 6f 64 20 3c 3c 27 45 4e |X//" >go|od <<'EN|
|00001380| 44 5f 4f 46 5f 67 6f 6f | 64 27 0a 58 31 30 30 20 |D_OF_goo|d'.X100 |
|00001390| 69 6e 74 73 20 6d 61 6c | 6c 6f 63 27 64 0a 58 32 |ints mal|loc'd.X2|
|000013a0| 30 30 20 69 6e 74 73 20 | 72 65 61 6c 6c 6f 63 27 |00 ints |realloc'|
|000013b0| 64 0a 58 32 35 20 69 6e | 74 73 20 6d 72 5f 61 6c |d.X25 in|ts mr_al|
|000013c0| 6c 6f 63 27 64 20 28 72 | 65 61 6c 6c 6f 63 27 64 |loc'd (r|ealloc'd|
|000013d0| 29 0a 58 35 30 30 20 69 | 6e 74 73 20 63 61 6c 6c |).X500 i|nts call|
|000013e0| 6f 63 27 64 0a 58 31 30 | 30 30 20 69 6e 74 73 20 |oc'd.X10|00 ints |
|000013f0| 6d 72 5f 61 6c 6c 6f 63 | 27 64 20 28 6d 61 6c 6c |mr_alloc|'d (mall|
|00001400| 6f 63 27 64 29 0a 58 35 | 30 20 69 6e 74 73 20 63 |oc'd).X5|0 ints c|
|00001410| 61 6c 6c 6f 63 27 64 20 | 28 6f 72 20 65 6c 73 65 |alloc'd |(or else|
|00001420| 29 0a 58 31 30 30 20 69 | 6e 74 73 20 6d 61 6c 6c |).X100 i|nts mall|
|00001430| 6f 63 27 64 20 28 6f 72 | 20 65 6c 73 65 29 0a 58 |oc'd (or| else).X|
|00001440| 32 30 30 20 69 6e 74 73 | 20 72 65 61 6c 6c 6f 63 |200 ints| realloc|
|00001450| 27 64 20 28 6f 72 20 65 | 6c 73 65 29 0a 58 34 30 |'d (or e|lse).X40|
|00001460| 30 20 69 6e 74 73 20 6d | 72 5f 61 6c 6c 6f 63 27 |0 ints m|r_alloc'|
|00001470| 64 20 28 72 65 61 6c 6c | 6f 63 27 64 29 20 28 6f |d (reall|oc'd) (o|
|00001480| 72 20 65 6c 73 65 29 0a | 45 4e 44 5f 4f 46 5f 67 |r else).|END_OF_g|
|00001490| 6f 6f 64 0a 69 66 20 74 | 65 73 74 20 32 34 34 20 |ood.if t|est 244 |
|000014a0| 2d 6e 65 20 60 77 63 20 | 2d 63 20 3c 67 6f 6f 64 |-ne `wc |-c <good|
|000014b0| 60 3b 20 74 68 65 6e 0a | 20 20 20 20 65 63 68 6f |`; then.| echo|
|000014c0| 20 73 68 61 72 3a 20 5c | 22 67 6f 6f 64 5c 22 20 | shar: \|"good\" |
|000014d0| 75 6e 70 61 63 6b 65 64 | 20 77 69 74 68 20 77 72 |unpacked| with wr|
|000014e0| 6f 6e 67 20 73 69 7a 65 | 21 0a 66 69 0a 23 20 65 |ong size|!.fi.# e|
|000014f0| 6e 64 20 6f 66 20 6f 76 | 65 72 77 72 69 74 69 6e |nd of ov|erwritin|
|00001500| 67 20 63 68 65 63 6b 0a | 66 69 0a 69 66 20 74 65 |g check.|fi.if te|
|00001510| 73 74 20 2d 66 20 6d 65 | 6d 6c 69 6e 74 6f 6b 2e |st -f me|mlintok.|
|00001520| 33 20 2d 61 20 22 24 7b | 31 7d 22 20 21 3d 20 22 |3 -a "${|1}" != "|
|00001530| 2d 63 22 20 3b 20 74 68 | 65 6e 20 0a 20 20 65 63 |-c" ; th|en . ec|
|00001540| 68 6f 20 73 68 61 72 3a | 20 57 69 6c 6c 20 6e 6f |ho shar:| Will no|
|00001550| 74 20 6f 76 65 72 2d 77 | 72 69 74 65 20 65 78 69 |t over-w|rite exi|
|00001560| 73 74 69 6e 67 20 66 69 | 6c 65 20 5c 22 6d 65 6d |sting fi|le \"mem|
|00001570| 6c 69 6e 74 6f 6b 2e 33 | 5c 22 0a 65 6c 73 65 0a |lintok.3|\".else.|
|00001580| 65 63 68 6f 20 73 68 61 | 72 3a 20 45 78 74 72 61 |echo sha|r: Extra|
|00001590| 63 74 69 6e 67 20 5c 22 | 6d 65 6d 6c 69 6e 74 6f |cting \"|memlinto|
|000015a0| 6b 2e 33 5c 22 20 5c 28 | 34 37 30 36 20 63 68 61 |k.3\" \(|4706 cha|
|000015b0| 72 61 63 74 65 72 73 5c | 29 0a 73 65 64 20 22 73 |racters\|).sed "s|
|000015c0| 2f 5e 58 2f 2f 22 20 3e | 6d 65 6d 6c 69 6e 74 6f |/^X//" >|memlinto|
|000015d0| 6b 2e 33 20 3c 3c 27 45 | 4e 44 5f 4f 46 5f 6d 65 |k.3 <<'E|ND_OF_me|
|000015e0| 6d 6c 69 6e 74 6f 6b 2e | 33 27 0a 58 2e 54 48 20 |mlintok.|3'.X.TH |
|000015f0| 4c 49 4e 54 4f 4b 20 33 | 20 22 32 20 4d 61 79 20 |LINTOK 3| "2 May |
|00001600| 31 39 38 39 22 0a 58 2e | 53 48 20 4e 41 4d 45 0a |1989".X.|SH NAME.|
|00001610| 58 6d 65 6d 6c 69 6e 74 | 6f 6b 20 5c 2d 20 70 61 |Xmemlint|ok \- pa|
|00001620| 63 6b 61 67 65 20 74 6f | 20 73 74 6f 70 20 6c 69 |ckage to| stop li|
|00001630| 6e 74 20 63 6f 6d 70 6c | 61 69 6e 74 73 20 61 62 |nt compl|aints ab|
|00001640| 6f 75 74 20 6d 65 6d 6f | 72 79 20 61 6c 6c 6f 63 |out memo|ry alloc|
|00001650| 61 74 69 6f 6e 0a 58 2e | 53 48 20 53 59 4e 4f 50 |ation.X.|SH SYNOP|
|00001660| 53 49 53 0a 58 2e 4c 50 | 0a 58 23 69 6e 63 6c 75 |SIS.X.LP|.X#inclu|
|00001670| 64 65 20 22 6d 65 6d 6c | 69 6e 74 6f 6b 2e 68 22 |de "meml|intok.h"|
|00001680| 0a 58 2e 53 48 20 44 45 | 53 43 52 49 50 54 49 4f |.X.SH DE|SCRIPTIO|
|00001690| 4e 0a 58 2e 4c 50 0a 58 | 54 68 69 73 20 70 61 63 |N.X.LP.X|This pac|
|000016a0| 6b 61 67 65 20 63 6f 6e | 74 61 69 6e 73 20 63 70 |kage con|tains cp|
|000016b0| 70 20 6d 61 63 72 6f 20 | 64 65 66 69 6e 69 74 69 |p macro |definiti|
|000016c0| 6f 6e 73 20 74 68 61 74 | 0a 58 73 74 6f 70 20 6c |ons that|.Xstop l|
|000016d0| 69 6e 74 20 66 72 6f 6d | 20 63 6f 6d 70 6c 61 69 |int from| complai|
|000016e0| 6e 69 6e 67 20 61 62 6f | 75 74 20 74 68 65 20 6d |ning abo|ut the m|
|000016f0| 65 6d 6f 72 79 20 6d 61 | 6e 61 67 65 6d 65 6e 74 |emory ma|nagement|
|00001700| 20 66 75 6e 63 74 69 6f | 6e 73 0a 58 2e 49 52 20 | functio|ns.X.IR |
|00001710| 6d 61 6c 6c 6f 63 20 28 | 33 29 2c 0a 58 2e 49 52 |malloc (|3),.X.IR|
|00001720| 20 63 61 6c 6c 6f 63 20 | 28 33 29 2c 0a 58 2e 49 | calloc |(3),.X.I|
|00001730| 52 20 72 65 61 6c 6c 6f | 63 20 28 33 29 2c 0a 58 |R reallo|c (3),.X|
|00001740| 61 6e 64 0a 58 2e 49 52 | 20 66 72 65 65 20 28 33 |and.X.IR| free (3|
|00001750| 29 0a 58 28 68 65 72 65 | 61 66 74 65 72 2c 20 77 |).X(here|after, w|
|00001760| 65 27 6c 6c 20 63 61 6c | 6c 20 74 68 65 73 65 20 |e'll cal|l these |
|00001770| 74 68 65 20 22 5c 66 49 | 2a 61 6c 6c 6f 63 5c 66 |the "\fI|*alloc\f|
|00001780| 50 28 33 29 22 20 66 75 | 6e 63 74 69 6f 6e 73 29 |P(3)" fu|nctions)|
|00001790| 2c 0a 58 77 68 69 6c 65 | 20 61 74 20 74 68 65 20 |,.Xwhile| at the |
|000017a0| 73 61 6d 65 20 74 69 6d | 65 20 70 65 72 66 6f 72 |same tim|e perfor|
|000017b0| 6d 69 6e 67 20 63 68 65 | 63 6b 73 20 6f 66 20 74 |ming che|cks of t|
|000017c0| 68 65 69 72 20 61 72 67 | 75 6d 65 6e 74 73 2e 0a |heir arg|uments..|
|000017d0| 58 54 68 65 72 65 20 61 | 72 65 20 74 77 6f 20 73 |XThere a|re two s|
|000017e0| 65 74 73 20 6f 66 20 6d | 61 63 72 6f 73 20 64 65 |ets of m|acros de|
|000017f0| 66 69 6e 65 64 20 68 65 | 72 65 3a 20 6f 6e 65 20 |fined he|re: one |
|00001800| 77 69 74 68 6f 75 74 20 | 65 78 63 65 70 74 69 6f |without |exceptio|
|00001810| 6e 20 68 61 6e 64 6c 69 | 6e 67 0a 58 28 6c 69 6b |n handli|ng.X(lik|
|00001820| 65 20 74 68 65 0a 58 2e | 49 52 20 2a 61 6c 6c 6f |e the.X.|IR *allo|
|00001830| 63 20 28 33 29 0a 58 66 | 75 6e 63 74 69 6f 6e 73 |c (3).Xf|unctions|
|00001840| 20 74 68 65 6d 73 65 6c | 76 65 73 29 20 61 6e 64 | themsel|ves) and|
|00001850| 20 6f 6e 65 20 77 69 74 | 68 2e 0a 58 2e 4c 50 0a | one wit|h..X.LP.|
|00001860| 58 54 68 65 20 6d 61 63 | 72 6f 73 20 77 69 74 68 |XThe mac|ros with|
|00001870| 6f 75 74 20 65 78 63 65 | 70 74 69 6f 6e 20 68 61 |out exce|ption ha|
|00001880| 6e 64 6c 69 6e 67 20 61 | 72 65 3a 0a 58 2e 49 50 |ndling a|re:.X.IP|
|00001890| 20 22 22 0a 58 43 41 4c | 4c 4f 43 5f 4c 49 4e 54 | "".XCAL|LOC_LINT|
|000018a0| 4f 4b 28 70 74 72 2c 20 | 6e 65 6c 65 6d 2c 20 74 |OK(ptr, |nelem, t|
|000018b0| 79 70 65 29 0a 58 2e 62 | 72 0a 58 4d 41 4c 4c 4f |ype).X.b|r.XMALLO|
|000018c0| 43 5f 4c 49 4e 54 4f 4b | 28 70 74 72 2c 20 6e 65 |C_LINTOK|(ptr, ne|
|000018d0| 6c 65 6d 2c 20 74 79 70 | 65 29 0a 58 2e 62 72 0a |lem, typ|e).X.br.|
|000018e0| 58 52 45 41 4c 4c 4f 43 | 5f 4c 49 4e 54 4f 4b 28 |XREALLOC|_LINTOK(|
|000018f0| 70 74 72 2c 20 6e 65 6c | 65 6d 2c 20 74 79 70 65 |ptr, nel|em, type|
|00001900| 29 0a 58 2e 62 72 0a 58 | 46 52 45 45 5f 4c 49 4e |).X.br.X|FREE_LIN|
|00001910| 54 4f 4b 28 70 74 72 29 | 0a 58 2e 62 72 0a 58 2e |TOK(ptr)|.X.br.X.|
|00001920| 4c 50 0a 58 77 68 65 72 | 65 20 22 70 74 72 22 20 |LP.Xwher|e "ptr" |
|00001930| 69 73 20 61 20 76 61 72 | 69 61 62 6c 65 20 6f 66 |is a var|iable of|
|00001940| 20 74 79 70 65 20 22 74 | 79 70 65 20 2a 22 2e 20 | type "t|ype *". |
|00001950| 20 41 66 74 65 72 20 69 | 6e 76 6f 6b 69 6e 67 20 | After i|nvoking |
|00001960| 61 6e 79 0a 58 6f 66 20 | 74 68 65 20 22 2a 41 4c |any.Xof |the "*AL|
|00001970| 4c 4f 43 5f 4c 49 4e 54 | 4f 4b 22 20 6d 61 63 72 |LOC_LINT|OK" macr|
|00001980| 6f 73 2c 20 22 70 74 72 | 22 20 77 69 6c 6c 20 65 |os, "ptr|" will e|
|00001990| 69 74 68 65 72 20 62 65 | 20 4e 55 4c 4c 20 28 69 |ither be| NULL (i|
|000019a0| 66 20 61 6e 64 0a 58 6f | 6e 6c 79 20 69 66 20 74 |f and.Xo|nly if t|
|000019b0| 68 65 0a 58 75 6e 64 65 | 72 6c 79 69 6e 67 20 66 |he.Xunde|rlying f|
|000019c0| 75 6e 63 74 69 6f 6e 20 | 72 65 74 75 72 6e 65 64 |unction |returned|
|000019d0| 20 69 74 29 20 6f 72 20 | 69 74 20 77 69 6c 6c 20 | it) or |it will |
|000019e0| 70 6f 69 6e 74 20 74 6f | 20 61 6e 20 61 72 72 61 |point to| an arra|
|000019f0| 79 20 6f 66 0a 58 22 6e | 65 6c 65 6d 22 20 6f 62 |y of.X"n|elem" ob|
|00001a00| 6a 65 63 74 73 20 6f 66 | 20 74 79 70 65 20 22 74 |jects of| type "t|
|00001a10| 79 70 65 22 2e 0a 58 2e | 4c 50 0a 58 4e 6f 74 65 |ype"..X.|LP.XNote|
|00001a20| 20 74 68 61 74 20 74 68 | 65 20 75 73 61 67 65 20 | that th|e usage |
|00001a30| 6f 66 20 4d 41 4c 4c 4f | 43 5f 4c 49 4e 54 4f 4b |of MALLO|C_LINTOK|
|00001a40| 2c 20 43 41 4c 4c 4f 43 | 5f 4c 49 4e 54 4f 4b 2c |, CALLOC|_LINTOK,|
|00001a50| 20 61 6e 64 0a 58 52 45 | 41 4c 4c 4f 43 5f 4c 49 | and.XRE|ALLOC_LI|
|00001a60| 4e 54 4f 4b 20 72 65 71 | 75 69 72 65 73 20 6d 6f |NTOK req|uires mo|
|00001a70| 72 65 20 74 68 61 6e 20 | 61 20 6e 61 6d 65 20 63 |re than |a name c|
|00001a80| 68 61 6e 67 65 2e 20 20 | 41 6e 20 6f 72 69 67 69 |hange. |An origi|
|00001a90| 6e 61 6c 0a 58 63 61 6c | 6c 20 6f 66 20 74 68 65 |nal.Xcal|l of the|
|00001aa0| 20 66 6f 72 6d 3a 0a 58 | 2e 49 50 0a 58 70 74 72 | form:.X|.IP.Xptr|
|00001ab0| 20 3d 20 28 74 79 70 65 | 20 2a 29 20 6d 61 6c 6c | = (type| *) mall|
|00001ac0| 6f 63 28 6e 65 6c 65 6d | 20 2a 20 73 69 7a 65 6f |oc(nelem| * sizeo|
|00001ad0| 66 28 74 79 70 65 29 29 | 0a 58 2e 4c 50 0a 58 6d |f(type))|.X.LP.Xm|
|00001ae0| 75 73 74 20 62 65 20 72 | 65 70 6c 61 63 65 64 20 |ust be r|eplaced |
|00001af0| 62 79 0a 58 2e 49 50 0a | 58 4d 41 4c 4c 4f 43 5f |by.X.IP.|XMALLOC_|
|00001b00| 4c 49 4e 54 4f 4b 28 70 | 74 72 2c 20 6e 65 6c 65 |LINTOK(p|tr, nele|
|00001b10| 6d 2c 20 74 79 70 65 29 | 0a 58 2e 4c 50 0a 58 61 |m, type)|.X.LP.Xa|
|00001b20| 6e 64 20 73 69 6d 69 6c | 61 72 6c 79 20 66 6f 72 |nd simil|arly for|
|00001b30| 20 43 41 4c 4c 4f 43 5f | 4c 49 4e 54 4f 4b 20 61 | CALLOC_|LINTOK a|
|00001b40| 6e 64 20 52 45 41 4c 4c | 4f 43 5f 4c 49 4e 54 4f |nd REALL|OC_LINTO|
|00001b50| 4b 2e 20 20 41 6c 6c 20 | 74 68 72 65 65 0a 58 6d |K. All |three.Xm|
|00001b60| 61 63 72 6f 73 20 22 72 | 65 74 75 72 6e 22 20 76 |acros "r|eturn" v|
|00001b70| 61 6c 75 65 73 20 61 6e | 64 20 6d 61 79 20 74 68 |alues an|d may th|
|00001b80| 65 72 65 66 6f 72 65 20 | 62 65 20 75 73 65 64 20 |erefore |be used |
|00001b90| 61 73 20 70 61 72 74 20 | 6f 66 0a 58 65 78 70 72 |as part |of.Xexpr|
|00001ba0| 65 73 73 69 6f 6e 73 2e | 0a 58 2e 4c 50 0a 58 49 |essions.|.X.LP.XI|
|00001bb0| 66 20 61 20 6d 61 63 72 | 6f 27 73 20 72 65 73 75 |f a macr|o's resu|
|00001bc0| 6c 74 20 69 73 20 63 6f | 6d 70 61 72 65 64 20 77 |lt is co|mpared w|
|00001bd0| 69 74 68 20 4e 55 4c 4c | 2c 20 6c 69 6e 74 20 77 |ith NULL|, lint w|
|00001be0| 69 6c 6c 20 75 73 75 61 | 6c 6c 79 20 63 6f 6d 70 |ill usua|lly comp|
|00001bf0| 6c 61 69 6e 0a 58 69 66 | 20 4e 55 4c 4c 20 69 73 |lain.Xif| NULL is|
|00001c00| 20 63 61 73 74 20 74 6f | 20 61 6e 79 74 68 69 6e | cast to| anythin|
|00001c10| 67 2e 20 20 46 6f 72 20 | 65 78 61 6d 70 6c 65 2c |g. For |example,|
|00001c20| 20 74 68 69 73 20 77 69 | 6c 6c 20 70 72 6f 64 75 | this wi|ll produ|
|00001c30| 63 65 20 61 20 6c 69 6e | 74 20 65 72 72 6f 72 3a |ce a lin|t error:|
|00001c40| 0a 58 2e 49 50 0a 58 69 | 6e 74 20 2a 69 61 3b 0a |.X.IP.Xi|nt *ia;.|
|00001c50| 58 2e 62 72 0a 58 20 2e | 2e 2e 0a 58 2e 62 72 0a |X.br.X .|...X.br.|
|00001c60| 58 69 66 20 28 4d 41 4c | 4c 4f 43 5f 4c 49 4e 54 |Xif (MAL|LOC_LINT|
|00001c70| 4f 4b 28 69 61 2c 20 34 | 32 2c 20 69 6e 74 29 20 |OK(ia, 4|2, int) |
|00001c80| 3d 3d 20 28 69 6e 74 20 | 2a 29 20 4e 55 4c 4c 29 |== (int |*) NULL)|
|00001c90| 0a 58 2e 62 72 0a 58 20 | 2e 2e 2e 0a 58 2e 4c 50 |.X.br.X |....X.LP|
|00001ca0| 0a 58 42 75 74 20 73 69 | 6e 63 65 20 75 6e 63 61 |.XBut si|nce unca|
|00001cb0| 73 74 20 30 20 28 69 2e | 65 2e 2c 20 4e 55 4c 4c |st 0 (i.|e., NULL|
|00001cc0| 29 20 69 73 20 61 6c 77 | 61 79 73 20 61 20 76 61 |) is alw|ays a va|
|00001cd0| 6c 69 64 20 70 6f 69 6e | 74 65 72 2c 20 69 74 0a |lid poin|ter, it.|
|00001ce0| 58 69 73 20 75 6e 6e 65 | 63 65 73 73 61 72 79 20 |Xis unne|cessary |
|00001cf0| 74 6f 20 63 61 73 74 20 | 69 74 20 74 6f 20 61 6e |to cast |it to an|
|00001d00| 79 74 68 69 6e 67 2e 0a | 58 52 65 6d 6f 76 69 6e |ything..|XRemovin|
|00001d10| 67 20 74 68 65 20 63 61 | 73 74 20 73 74 6f 70 73 |g the ca|st stops|
|00001d20| 20 74 68 65 20 6c 69 6e | 74 20 63 6f 6d 70 6c 61 | the lin|t compla|
|00001d30| 69 6e 74 3a 0a 58 2e 49 | 50 0a 58 20 2e 2e 2e 0a |int:.X.I|P.X ....|
|00001d40| 58 2e 62 72 0a 58 69 66 | 20 28 4d 41 4c 4c 4f 43 |X.br.Xif| (MALLOC|
|00001d50| 5f 4c 49 4e 54 4f 4b 28 | 69 61 2c 20 34 32 2c 20 |_LINTOK(|ia, 42, |
|00001d60| 69 6e 74 29 20 3d 3d 20 | 4e 55 4c 4c 29 0a 58 2e |int) == |NULL).X.|
|00001d70| 62 72 0a 58 20 2e 2e 2e | 0a 58 2e 4c 50 0a 58 49 |br.X ...|.X.LP.XI|
|00001d80| 66 20 74 68 65 20 6d 61 | 63 72 6f 20 69 6e 76 6f |f the ma|cro invo|
|00001d90| 63 61 74 69 6f 6e 20 64 | 6f 65 73 6e 27 74 20 61 |cation d|oesn't a|
|00001da0| 70 70 65 61 72 20 77 69 | 74 68 69 6e 20 61 6e 20 |ppear wi|thin an |
|00001db0| 65 78 70 72 65 73 73 69 | 6f 6e 2c 0a 58 79 6f 75 |expressi|on,.Xyou|
|00001dc0| 20 77 69 6c 6c 20 6e 65 | 65 64 20 74 6f 20 63 61 | will ne|ed to ca|
|00001dd0| 73 74 20 74 68 65 20 2a | 41 4c 4c 4f 43 5f 4c 49 |st the *|ALLOC_LI|
|00001de0| 4e 54 4f 4b 28 29 0a 58 | 69 6e 76 6f 63 61 74 69 |NTOK().X|invocati|
|00001df0| 6f 6e 73 20 74 6f 0a 58 | 2e 42 20 76 6f 69 64 0a |ons to.X|.B void.|
|00001e00| 58 69 66 20 79 6f 75 20 | 77 61 6e 74 20 74 6f 20 |Xif you |want to |
|00001e10| 67 65 74 20 72 69 64 20 | 6f 66 20 74 68 65 0a 58 |get rid |of the.X|
|00001e20| 22 2a 61 6c 6c 6f 63 20 | 72 65 74 75 72 6e 73 20 |"*alloc |returns |
|00001e30| 76 61 6c 75 65 20 77 68 | 69 63 68 20 69 73 20 73 |value wh|ich is s|
|00001e40| 6f 6d 65 74 69 6d 65 73 | 20 69 67 6e 6f 72 65 64 |ometimes| ignored|
|00001e50| 22 0a 58 61 6e 64 0a 58 | 22 2a 61 6c 6c 6f 63 20 |".Xand.X|"*alloc |
|00001e60| 72 65 74 75 72 6e 73 20 | 76 61 6c 75 65 20 77 68 |returns |value wh|
|00001e70| 69 63 68 20 69 73 20 61 | 6c 77 61 79 73 20 69 67 |ich is a|lways ig|
|00001e80| 6e 6f 72 65 64 22 0a 58 | 6d 65 73 73 61 67 65 73 |nored".X|messages|
|00001e90| 2e 0a 58 2e 4c 50 0a 58 | 59 6f 75 20 63 61 6e 20 |..X.LP.X|You can |
|00001ea0| 6d 69 78 20 69 6e 76 6f | 63 61 74 69 6f 6e 73 20 |mix invo|cations |
|00001eb0| 6f 66 20 74 68 65 73 65 | 20 6d 61 63 72 6f 73 20 |of these| macros |
|00001ec0| 77 69 74 68 20 63 61 6c | 6c 73 20 74 6f 20 74 68 |with cal|ls to th|
|00001ed0| 65 20 6f 72 69 67 69 6e | 61 6c 0a 58 66 75 6e 63 |e origin|al.Xfunc|
|00001ee0| 74 69 6f 6e 73 2e 20 20 | 54 68 65 20 6f 6e 6c 79 |tions. |The only|
|00001ef0| 20 64 69 66 66 65 72 65 | 6e 63 65 20 69 73 20 69 | differe|nce is i|
|00001f00| 6e 20 74 68 65 20 6c 69 | 6e 74 20 62 65 68 61 76 |n the li|nt behav|
|00001f10| 69 6f 72 2e 0a 58 2e 4c | 50 0a 58 41 20 63 6f 6d |ior..X.L|P.XA com|
|00001f20| 6d 6f 6e 20 77 61 79 20 | 6f 66 20 69 6e 76 6f 6b |mon way |of invok|
|00001f30| 69 6e 67 20 74 68 65 20 | 6d 65 6d 6f 72 79 20 6d |ing the |memory m|
|00001f40| 61 6e 61 67 65 6d 65 6e | 74 20 66 75 6e 63 74 69 |anagemen|t functi|
|00001f50| 6f 6e 73 20 69 73 20 74 | 6f 20 63 61 6c 6c 0a 58 |ons is t|o call.X|
|00001f60| 2e 49 52 20 6d 61 6c 6c | 6f 63 20 28 29 0a 58 69 |.IR mall|oc ().Xi|
|00001f70| 66 20 61 0a 58 70 6f 69 | 6e 74 65 72 20 69 73 20 |f a.Xpoi|nter is |
|00001f80| 4e 55 4c 4c 20 28 75 73 | 75 61 6c 6c 79 20 74 68 |NULL (us|ually th|
|00001f90| 65 20 66 69 72 73 74 20 | 74 69 6d 65 20 69 74 27 |e first |time it'|
|00001fa0| 73 20 73 65 74 29 20 61 | 6e 64 0a 58 2e 49 52 20 |s set) a|nd.X.IR |
|00001fb0| 72 65 61 6c 6c 6f 63 20 | 28 29 0a 58 69 66 20 69 |realloc |().Xif i|
|00001fc0| 74 20 69 73 6e 27 74 20 | 4e 55 4c 4c 20 28 75 73 |t isn't |NULL (us|
|00001fd0| 75 61 6c 6c 79 20 6f 6e | 20 73 75 62 73 65 71 75 |ually on| subsequ|
|00001fe0| 65 6e 74 20 74 69 6d 65 | 73 29 2e 20 20 54 68 65 |ent time|s). The|
|00001ff0| 20 73 69 6d 70 6c 65 20 | 6d 61 63 72 6f 0a 58 2e | simple |macro.X.|
|00002000| 49 50 0a 58 4d 52 5f 41 | 4c 4c 4f 43 5f 4c 49 4e |IP.XMR_A|LLOC_LIN|
|00002010| 54 4f 4b 28 70 74 72 2c | 20 6e 65 6c 65 6d 2c 20 |TOK(ptr,| nelem, |
|00002020| 74 79 70 65 29 0a 58 2e | 4c 50 0a 58 64 6f 65 73 |type).X.|LP.Xdoes|
|00002030| 20 74 68 69 73 20 77 69 | 74 68 20 4d 41 4c 4c 4f | this wi|th MALLO|
|00002040| 43 5f 4c 49 4e 54 4f 4b | 28 29 20 61 6e 64 20 52 |C_LINTOK|() and R|
|00002050| 45 41 4c 4c 4f 43 5f 4c | 49 4e 54 4f 4b 28 29 2e |EALLOC_L|INTOK().|
|00002060| 0a 58 2e 4c 50 0a 58 53 | 69 6e 63 65 20 6d 65 6d |.X.LP.XS|ince mem|
|00002070| 6f 72 79 20 61 6c 6c 6f | 63 61 74 69 6f 6e 20 66 |ory allo|cation f|
|00002080| 61 69 6c 75 72 65 20 69 | 73 20 6f 66 74 65 6e 20 |ailure i|s often |
|00002090| 61 6e 20 65 78 63 65 70 | 74 69 6f 6e 61 6c 20 63 |an excep|tional c|
|000020a0| 6f 6e 64 69 74 69 6f 6e | 2c 0a 58 22 6d 65 6d 6c |ondition|,.X"meml|
|000020b0| 69 6e 74 6f 6b 2e 68 22 | 20 61 6c 73 6f 20 68 61 |intok.h"| also ha|
|000020c0| 73 20 64 65 66 69 6e 69 | 74 69 6f 6e 73 20 6f 66 |s defini|tions of|
|000020d0| 20 66 6f 75 72 20 6f 74 | 68 65 72 20 75 73 65 66 | four ot|her usef|
|000020e0| 75 6c 20 6d 61 63 72 6f | 73 20 74 68 61 74 20 69 |ul macro|s that i|
|000020f0| 6e 63 6c 75 64 65 0a 58 | 65 78 63 65 70 74 69 6f |nclude.X|exceptio|
|00002100| 6e 20 68 61 6e 64 6c 69 | 6e 67 3a 0a 58 2e 49 50 |n handli|ng:.X.IP|
|00002110| 0a 58 43 41 4c 4c 4f 43 | 5f 4f 52 5f 45 4c 53 45 |.XCALLOC|_OR_ELSE|
|00002120| 5f 4c 49 4e 54 4f 4b 28 | 70 74 72 2c 20 6e 65 6c |_LINTOK(|ptr, nel|
|00002130| 65 6d 2c 20 74 79 70 65 | 29 0a 58 2e 62 72 0a 58 |em, type|).X.br.X|
|00002140| 4d 41 4c 4c 4f 43 5f 4f | 52 5f 45 4c 53 45 5f 4c |MALLOC_O|R_ELSE_L|
|00002150| 49 4e 54 4f 4b 28 70 74 | 72 2c 20 6e 65 6c 65 6d |INTOK(pt|r, nelem|
|00002160| 2c 20 74 79 70 65 29 0a | 58 2e 62 72 0a 58 52 45 |, type).|X.br.XRE|
|00002170| 41 4c 4c 4f 43 5f 4f 52 | 5f 45 4c 53 45 5f 4c 49 |ALLOC_OR|_ELSE_LI|
|00002180| 4e 54 4f 4b 28 70 74 72 | 2c 20 6e 65 6c 65 6d 2c |NTOK(ptr|, nelem,|
|00002190| 20 74 79 70 65 29 0a 58 | 2e 62 72 0a 58 4d 52 5f | type).X|.br.XMR_|
|000021a0| 41 4c 4c 4f 43 5f 4f 52 | 5f 45 4c 53 45 5f 4c 49 |ALLOC_OR|_ELSE_LI|
|000021b0| 4e 54 4f 4b 28 70 74 72 | 2c 20 6e 65 6c 65 6d 2c |NTOK(ptr|, nelem,|
|000021c0| 20 74 79 70 65 29 0a 58 | 2e 62 72 0a 58 2e 4c 50 | type).X|.br.X.LP|
|000021d0| 0a 58 45 61 63 68 20 6f | 66 20 74 68 65 73 65 20 |.XEach o|f these |
|000021e0| 6d 61 63 72 6f 73 20 69 | 6e 76 6f 6b 65 73 20 74 |macros i|nvokes t|
|000021f0| 68 65 20 63 6f 72 72 65 | 73 70 6f 6e 64 69 6e 67 |he corre|sponding|
|00002200| 20 2a 41 4c 4c 4f 43 5f | 4c 49 4e 54 4f 4b 28 29 | *ALLOC_|LINTOK()|
|00002210| 20 6d 61 63 72 6f 20 61 | 6e 64 2c 0a 58 69 66 20 | macro a|nd,.Xif |
|00002220| 74 68 61 74 20 6d 61 63 | 72 6f 20 66 61 69 6c 73 |that mac|ro fails|
|00002230| 2c 20 69 6e 76 6f 6b 65 | 73 20 61 6e 6f 74 68 65 |, invoke|s anothe|
|00002240| 72 20 6d 61 63 72 6f 3a | 0a 58 2e 49 50 0a 58 45 |r macro:|.X.IP.XE|
|00002250| 52 52 4f 52 5f 45 58 49 | 54 5f 4c 49 4e 54 4f 4b |RROR_EXI|T_LINTOK|
|00002260| 28 6e 65 6c 65 6d 2c 20 | 73 69 7a 65 29 0a 58 2e |(nelem, |size).X.|
|00002270| 4c 50 0a 58 57 68 65 72 | 65 20 22 6e 65 6c 65 6d |LP.XWher|e "nelem|
|00002280| 22 20 69 73 20 74 68 65 | 20 6e 75 6d 62 65 72 20 |" is the| number |
|00002290| 6f 66 20 65 6c 65 6d 65 | 6e 74 73 20 6f 66 20 22 |of eleme|nts of "|
|000022a0| 73 69 7a 65 22 20 62 79 | 74 65 73 20 61 74 74 65 |size" by|tes atte|
|000022b0| 6d 70 74 69 6e 67 20 74 | 6f 20 62 65 0a 58 61 6c |mpting t|o be.Xal|
|000022c0| 6c 6f 63 61 74 65 64 2e | 0a 58 2e 4c 50 0a 58 41 |located.|.X.LP.XA|
|000022d0| 20 64 65 66 61 75 6c 74 | 20 45 52 52 4f 52 5f 45 | default| ERROR_E|
|000022e0| 58 49 54 5f 4c 49 4e 54 | 4f 4b 28 6e 65 6c 65 6d |XIT_LINT|OK(nelem|
|000022f0| 2c 20 73 69 7a 65 29 2c | 20 77 68 69 63 68 20 70 |, size),| which p|
|00002300| 72 69 6e 74 73 20 61 6e | 20 69 6e 66 6f 72 6d 61 |rints an| informa|
|00002310| 74 69 76 65 0a 58 6d 65 | 73 73 61 67 65 20 61 6e |tive.Xme|ssage an|
|00002320| 64 20 64 69 65 73 2c 20 | 69 73 20 61 6c 73 6f 20 |d dies, |is also |
|00002330| 64 65 66 69 6e 65 64 2c | 20 62 75 74 20 79 6f 75 |defined,| but you|
|00002340| 20 61 72 65 20 66 72 65 | 65 20 74 6f 20 72 65 64 | are fre|e to red|
|00002350| 65 66 69 6e 65 20 69 74 | 0a 58 28 61 66 74 65 72 |efine it|.X(after|
|00002360| 20 69 6e 63 6c 75 64 69 | 6e 67 20 22 6d 65 6d 6c | includi|ng "meml|
|00002370| 69 6e 74 6f 6b 2e 68 22 | 20 61 6e 64 20 62 65 66 |intok.h"| and bef|
|00002380| 6f 72 65 20 69 6e 76 6f | 6b 69 6e 67 20 61 6e 79 |ore invo|king any|
|00002390| 20 6f 66 20 74 68 65 20 | 6d 61 63 72 6f 73 20 68 | of the |macros h|
|000023a0| 65 72 65 69 6e 0a 58 2d | 2d 20 72 65 6d 65 6d 62 |erein.X-|- rememb|
|000023b0| 65 72 20 74 6f 20 22 23 | 75 6e 64 65 66 20 45 52 |er to "#|undef ER|
|000023c0| 52 4f 52 5f 45 58 49 54 | 5f 4c 49 4e 54 4f 4b 22 |ROR_EXIT|_LINTOK"|
|000023d0| 20 66 69 72 73 74 29 0a | 58 69 66 20 79 6f 75 20 | first).|Xif you |
|000023e0| 77 61 6e 74 20 74 6f 20 | 64 6f 20 79 6f 75 72 20 |want to |do your |
|000023f0| 6f 77 6e 20 65 72 72 6f | 72 20 68 61 6e 64 6c 69 |own erro|r handli|
|00002400| 6e 67 2e 0a 58 2e 53 48 | 20 22 53 45 45 20 41 4c |ng..X.SH| "SEE AL|
|00002410| 53 4f 22 0a 58 2e 42 52 | 20 6d 61 6c 6c 6f 63 20 |SO".X.BR| malloc |
|00002420| 28 33 29 2c 0a 58 2e 42 | 52 20 73 74 64 69 6f 20 |(3),.X.B|R stdio |
|00002430| 28 33 53 29 0a 58 2e 53 | 48 20 4e 4f 54 45 0a 58 |(3S).X.S|H NOTE.X|
|00002440| 2e 4c 50 0a 58 22 6d 65 | 6d 6c 69 6e 74 6f 6b 2e |.LP.X"me|mlintok.|
|00002450| 68 22 20 61 73 73 75 6d | 65 73 20 4e 55 4c 4c 20 |h" assum|es NULL |
|00002460| 69 73 20 64 65 66 69 6e | 65 64 20 69 6e 20 3c 73 |is defin|ed in <s|
|00002470| 74 64 69 6f 2e 68 3e 20 | 28 77 68 69 63 68 20 69 |tdio.h> |(which i|
|00002480| 73 20 75 73 75 61 6c 6c | 79 20 74 68 65 20 63 61 |s usuall|y the ca|
|00002490| 73 65 29 2e 0a 58 2e 4c | 50 0a 58 49 74 20 61 6c |se)..X.L|P.XIt al|
|000024a0| 73 6f 20 61 73 73 75 6d | 65 73 20 74 68 65 20 63 |so assum|es the c|
|000024b0| 70 70 20 73 79 6d 62 6f | 6c 20 22 6c 69 6e 74 22 |pp symbo|l "lint"|
|000024c0| 20 69 73 20 64 65 66 69 | 6e 65 64 20 77 68 65 6e | is defi|ned when|
|000024d0| 20 61 6e 64 20 6f 6e 6c | 79 20 77 68 65 6e 20 74 | and onl|y when t|
|000024e0| 68 65 0a 58 63 6f 64 65 | 20 69 73 20 62 65 69 6e |he.Xcode| is bein|
|000024f0| 67 20 70 61 73 73 65 64 | 20 74 68 72 6f 75 67 68 |g passed| through|
|00002500| 20 6c 69 6e 74 20 61 6e | 64 20 6e 6f 74 20 67 65 | lint an|d not ge|
|00002510| 6e 65 72 61 74 69 6e 67 | 20 72 65 61 6c 20 65 78 |nerating| real ex|
|00002520| 65 63 75 74 61 62 6c 65 | 20 63 6f 64 65 2e 0a 58 |ecutable| code..X|
|00002530| 2e 4c 50 0a 58 54 68 65 | 73 65 20 6d 61 63 72 6f |.LP.XThe|se macro|
|00002540| 73 20 68 61 76 65 20 62 | 65 65 6e 20 74 65 73 74 |s have b|een test|
|00002550| 65 64 20 75 6e 64 65 72 | 20 53 75 6e 4f 53 2c 20 |ed under| SunOS, |
|00002560| 48 50 2d 55 58 2c 20 61 | 6e 64 20 41 70 6f 6c 6c |HP-UX, a|nd Apoll|
|00002570| 6f 20 44 4f 4d 41 49 4e | 2f 49 58 2e 0a 58 2e 53 |o DOMAIN|/IX..X.S|
|00002580| 48 20 42 55 47 53 0a 58 | 2e 4c 50 0a 58 54 68 65 |H BUGS.X|.LP.XThe|
|00002590| 73 65 20 6d 61 63 72 6f | 73 20 61 72 65 20 69 6e |se macro|s are in|
|000025a0| 74 65 6e 64 65 64 20 66 | 6f 72 20 75 73 65 20 77 |tended f|or use w|
|000025b0| 69 74 68 20 74 68 65 20 | 64 79 6e 61 6d 69 63 0a |ith the |dynamic.|
|000025c0| 58 61 6c 6c 6f 63 61 74 | 69 6f 6e 20 6f 66 20 73 |Xallocat|ion of s|
|000025d0| 69 6e 67 6c 65 20 65 6c | 65 6d 65 6e 74 73 20 6f |ingle el|ements o|
|000025e0| 66 20 66 69 78 65 64 20 | 73 69 7a 65 20 28 69 2e |f fixed |size (i.|
|000025f0| 65 2e 20 73 74 72 75 63 | 74 73 20 6f 72 20 74 79 |e. struc|ts or ty|
|00002600| 70 65 64 65 66 73 29 0a | 58 6f 72 20 76 61 72 69 |pedefs).|Xor vari|
|00002610| 61 62 6c 79 2d 73 69 7a | 65 64 20 61 72 72 61 79 |ably-siz|ed array|
|00002620| 73 20 6f 66 20 73 61 6d | 65 2e 0a 58 49 6e 20 74 |s of sam|e..XIn t|
|00002630| 68 65 20 61 75 74 68 6f | 72 27 73 20 65 78 70 65 |he autho|r's expe|
|00002640| 72 69 65 6e 63 65 2c 20 | 74 68 69 73 20 63 6f 76 |rience, |this cov|
|00002650| 65 72 73 20 6d 6f 73 74 | 20 75 73 65 73 20 6f 66 |ers most| uses of|
|00002660| 20 74 68 65 0a 58 2e 49 | 52 20 5c 66 49 2a 61 6c | the.X.I|R \fI*al|
|00002670| 6c 6f 63 5c 66 50 20 28 | 33 29 0a 58 66 75 6e 63 |loc\fP (|3).Xfunc|
|00002680| 74 69 6f 6e 73 2e 0a 58 | 54 68 65 20 6d 61 63 72 |tions..X|The macr|
|00002690| 6f 73 20 64 6f 20 6e 6f | 74 20 77 6f 72 6b 20 77 |os do no|t work w|
|000026a0| 65 6c 6c 2c 20 68 6f 77 | 65 76 65 72 2c 20 77 68 |ell, how|ever, wh|
|000026b0| 65 6e 20 63 72 65 61 74 | 69 6e 67 20 76 61 72 69 |en creat|ing vari|
|000026c0| 61 62 6c 79 2d 73 69 7a | 65 64 20 73 69 6e 67 6c |ably-siz|ed singl|
|000026d0| 65 0a 58 73 74 72 75 63 | 74 75 72 65 73 20 74 68 |e.Xstruc|tures th|
|000026e0| 61 74 20 61 72 65 20 6e | 6f 74 20 61 72 72 61 79 |at are n|ot array|
|000026f0| 73 2e 0a 58 2e 4c 50 0a | 58 41 74 20 6c 65 61 73 |s..X.LP.|XAt leas|
|00002700| 74 20 6f 6e 65 20 76 65 | 72 73 69 6f 6e 20 6f 66 |t one ve|rsion of|
|00002710| 0a 58 2e 49 52 20 6c 69 | 6e 74 20 28 31 29 0a 58 |.X.IR li|nt (1).X|
|00002720| 28 53 75 6e 4f 53 20 34 | 2e 30 29 20 63 6f 6d 70 |(SunOS 4|.0) comp|
|00002730| 6c 61 69 6e 73 20 77 68 | 65 6e 20 74 68 65 73 65 |lains wh|en these|
|00002740| 20 6d 61 63 72 6f 73 0a | 58 61 72 65 20 75 73 65 | macros.|Xare use|
|00002750| 64 20 77 69 74 68 20 22 | 76 6f 69 64 20 2a 22 20 |d with "|void *" |
|00002760| 70 6f 69 6e 74 65 72 73 | 2e 0a 58 49 74 20 6e 65 |pointers|..XIt ne|
|00002770| 65 64 6e 27 74 2e 0a 58 | 2e 4c 50 0a 58 41 70 6f |edn't..X|.LP.XApo|
|00002780| 6c 6c 6f 20 44 4f 4d 41 | 49 4e 2f 49 58 0a 58 2e |llo DOMA|IN/IX.X.|
|00002790| 49 52 20 6c 69 6e 74 20 | 28 31 29 0a 58 67 65 6e |IR lint |(1).Xgen|
|000027a0| 65 72 61 74 65 73 20 73 | 65 76 65 72 61 6c 20 62 |erates s|everal b|
|000027b0| 6f 67 75 73 20 28 49 20 | 62 65 6c 69 65 76 65 29 |ogus (I |believe)|
|000027c0| 20 63 6f 6d 70 6c 61 69 | 6e 74 73 20 61 62 6f 75 | complai|nts abou|
|000027d0| 74 20 74 68 65 20 64 65 | 66 61 75 6c 74 20 65 78 |t the de|fault ex|
|000027e0| 63 65 70 74 69 6f 6e 0a | 58 68 61 6e 64 6c 69 6e |ception.|Xhandlin|
|000027f0| 67 20 6d 61 63 72 6f 2e | 0a 58 2e 53 48 20 41 55 |g macro.|.X.SH AU|
|00002800| 54 48 4f 52 0a 58 2e 4c | 50 0a 58 42 6f 62 20 4c |THOR.X.L|P.XBob L|
|00002810| 65 77 69 73 20 28 62 6f | 62 6c 40 74 65 73 73 69 |ewis (bo|bl@tessi|
|00002820| 2e 75 75 63 70 29 20 70 | 72 6f 64 75 63 65 64 20 |.uucp) p|roduced |
|00002830| 74 68 65 73 65 20 6d 61 | 63 72 6f 73 20 75 73 69 |these ma|cros usi|
|00002840| 6e 67 20 68 69 73 20 6f | 77 6e 0a 58 72 65 73 6f |ng his o|wn.Xreso|
|00002850| 75 72 63 65 73 20 61 6e | 64 20 68 65 72 65 62 79 |urces an|d hereby|
|00002860| 20 72 65 6c 65 61 73 65 | 73 20 74 68 65 6d 20 74 | release|s them t|
|00002870| 6f 20 74 68 65 20 70 75 | 62 6c 69 63 20 64 6f 6d |o the pu|blic dom|
|00002880| 61 69 6e 2e 0a 58 54 68 | 65 20 61 75 74 68 6f 72 |ain..XTh|e author|
|00002890| 20 77 69 6c 6c 20 6e 6f | 74 20 62 65 20 68 65 6c | will no|t be hel|
|000028a0| 64 20 72 65 73 70 6f 6e | 73 69 62 6c 65 20 66 6f |d respon|sible fo|
|000028b0| 72 20 74 68 65 69 72 20 | 75 73 65 2c 20 6d 69 73 |r their |use, mis|
|000028c0| 75 73 65 2c 0a 58 61 62 | 75 73 65 2c 20 6f 72 20 |use,.Xab|use, or |
|000028d0| 61 6e 79 20 64 61 6d 61 | 67 65 73 20 61 72 69 73 |any dama|ges aris|
|000028e0| 69 6e 67 20 66 72 6f 6d | 20 73 61 6d 65 2e 0a 45 |ing from| same..E|
|000028f0| 4e 44 5f 4f 46 5f 6d 65 | 6d 6c 69 6e 74 6f 6b 2e |ND_OF_me|mlintok.|
|00002900| 33 0a 69 66 20 74 65 73 | 74 20 34 37 30 36 20 2d |3.if tes|t 4706 -|
|00002910| 6e 65 20 60 77 63 20 2d | 63 20 3c 6d 65 6d 6c 69 |ne `wc -|c <memli|
|00002920| 6e 74 6f 6b 2e 33 60 3b | 20 74 68 65 6e 0a 20 20 |ntok.3`;| then. |
|00002930| 20 20 65 63 68 6f 20 73 | 68 61 72 3a 20 5c 22 6d | echo s|har: \"m|
|00002940| 65 6d 6c 69 6e 74 6f 6b | 2e 33 5c 22 20 75 6e 70 |emlintok|.3\" unp|
|00002950| 61 63 6b 65 64 20 77 69 | 74 68 20 77 72 6f 6e 67 |acked wi|th wrong|
|00002960| 20 73 69 7a 65 21 0a 66 | 69 0a 23 20 65 6e 64 20 | size!.f|i.# end |
|00002970| 6f 66 20 6f 76 65 72 77 | 72 69 74 69 6e 67 20 63 |of overw|riting c|
|00002980| 68 65 63 6b 0a 66 69 0a | 69 66 20 74 65 73 74 20 |heck.fi.|if test |
|00002990| 2d 66 20 6d 65 6d 6c 69 | 6e 74 6f 6b 2e 68 20 2d |-f memli|ntok.h -|
|000029a0| 61 20 22 24 7b 31 7d 22 | 20 21 3d 20 22 2d 63 22 |a "${1}"| != "-c"|
|000029b0| 20 3b 20 74 68 65 6e 20 | 0a 20 20 65 63 68 6f 20 | ; then |. echo |
|000029c0| 73 68 61 72 3a 20 57 69 | 6c 6c 20 6e 6f 74 20 6f |shar: Wi|ll not o|
|000029d0| 76 65 72 2d 77 72 69 74 | 65 20 65 78 69 73 74 69 |ver-writ|e existi|
|000029e0| 6e 67 20 66 69 6c 65 20 | 5c 22 6d 65 6d 6c 69 6e |ng file |\"memlin|
|000029f0| 74 6f 6b 2e 68 5c 22 0a | 65 6c 73 65 0a 65 63 68 |tok.h\".|else.ech|
|00002a00| 6f 20 73 68 61 72 3a 20 | 45 78 74 72 61 63 74 69 |o shar: |Extracti|
|00002a10| 6e 67 20 5c 22 6d 65 6d | 6c 69 6e 74 6f 6b 2e 68 |ng \"mem|lintok.h|
|00002a20| 5c 22 20 5c 28 32 39 38 | 36 20 63 68 61 72 61 63 |\" \(298|6 charac|
|00002a30| 74 65 72 73 5c 29 0a 73 | 65 64 20 22 73 2f 5e 58 |ters\).s|ed "s/^X|
|00002a40| 2f 2f 22 20 3e 6d 65 6d | 6c 69 6e 74 6f 6b 2e 68 |//" >mem|lintok.h|
|00002a50| 20 3c 3c 27 45 4e 44 5f | 4f 46 5f 6d 65 6d 6c 69 | <<'END_|OF_memli|
|00002a60| 6e 74 6f 6b 2e 68 27 0a | 58 23 69 66 6e 64 65 66 |ntok.h'.|X#ifndef|
|00002a70| 20 49 4e 43 4c 55 44 45 | 44 5f 4c 49 4e 54 4f 4b | INCLUDE|D_LINTOK|
|00002a80| 0a 58 0a 58 2f 2a 20 24 | 48 65 61 64 65 72 3a 20 |.X.X/* $|Header: |
|00002a90| 6d 65 6d 6c 69 6e 74 6f | 6b 2e 68 2c 76 20 31 2e |memlinto|k.h,v 1.|
|00002aa0| 33 20 38 39 2f 30 35 2f | 30 32 20 31 35 3a 30 31 |3 89/05/|02 15:01|
|00002ab0| 3a 34 33 20 62 6f 62 6c | 20 4c 6f 63 6b 65 64 20 |:43 bobl| Locked |
|00002ac0| 24 20 2a 2f 0a 58 0a 58 | 2f 2a 0a 58 20 2a 09 54 |$ */.X.X|/*.X *.T|
|00002ad0| 68 65 73 65 20 64 65 66 | 69 6e 69 74 69 6f 6e 73 |hese def|initions|
|00002ae0| 20 73 74 6f 70 20 6c 69 | 6e 74 20 66 72 6f 6d 20 | stop li|nt from |
|00002af0| 63 6f 6d 70 6c 61 69 6e | 69 6e 67 20 61 62 6f 75 |complain|ing abou|
|00002b00| 74 20 6d 61 6c 6c 6f 63 | 2c 20 63 61 6c 6c 6f 63 |t malloc|, calloc|
|00002b10| 2c 0a 58 20 2a 09 72 65 | 61 6c 6c 6f 63 2c 20 61 |,.X *.re|alloc, a|
|00002b20| 6e 64 20 66 72 65 65 20 | 77 68 69 6c 65 20 61 74 |nd free |while at|
|00002b30| 20 74 68 65 20 73 61 6d | 65 20 74 69 6d 65 20 70 | the sam|e time p|
|00002b40| 65 72 66 6f 72 6d 69 6e | 67 20 63 68 65 63 6b 73 |erformin|g checks|
|00002b50| 20 6f 66 0a 58 20 2a 09 | 74 68 65 69 72 20 61 72 | of.X *.|their ar|
|00002b60| 67 75 6d 65 6e 74 73 2e | 20 20 53 65 65 20 74 68 |guments.| See th|
|00002b70| 65 20 6d 65 6d 6c 69 6e | 74 6f 6b 28 33 29 20 6d |e memlin|tok(3) m|
|00002b80| 61 6e 20 70 61 67 65 20 | 66 6f 72 20 6d 6f 72 65 |an page |for more|
|00002b90| 20 64 65 74 61 69 6c 73 | 2e 0a 58 20 2a 0a 58 20 | details|..X *.X |
|00002ba0| 2a 09 42 6f 62 20 4c 65 | 77 69 73 20 28 62 6f 62 |*.Bob Le|wis (bob|
|00002bb0| 6c 40 74 65 73 73 69 2e | 75 75 63 70 29 20 70 72 |l@tessi.|uucp) pr|
|00002bc0| 6f 64 75 63 65 64 20 74 | 68 65 73 65 20 6d 61 63 |oduced t|hese mac|
|00002bd0| 72 6f 73 20 75 73 69 6e | 67 20 68 69 73 20 6f 77 |ros usin|g his ow|
|00002be0| 6e 0a 58 20 2a 09 72 65 | 73 6f 75 72 63 65 73 20 |n.X *.re|sources |
|00002bf0| 61 6e 64 20 68 65 72 65 | 62 79 20 72 65 6c 65 61 |and here|by relea|
|00002c00| 73 65 73 20 74 68 65 6d | 20 74 6f 20 74 68 65 20 |ses them| to the |
|00002c10| 70 75 62 6c 69 63 20 64 | 6f 6d 61 69 6e 2e 0a 58 |public d|omain..X|
|00002c20| 20 2a 09 54 68 65 20 61 | 75 74 68 6f 72 20 77 69 | *.The a|uthor wi|
|00002c30| 6c 6c 20 6e 6f 74 20 62 | 65 20 68 65 6c 64 20 72 |ll not b|e held r|
|00002c40| 65 73 70 6f 6e 73 69 62 | 6c 65 20 66 6f 72 20 74 |esponsib|le for t|
|00002c50| 68 65 69 72 20 75 73 65 | 2c 20 6d 69 73 75 73 65 |heir use|, misuse|
|00002c60| 2c 0a 58 20 2a 09 61 62 | 75 73 65 2c 20 6f 72 20 |,.X *.ab|use, or |
|00002c70| 61 6e 79 20 64 61 6d 61 | 67 65 73 20 61 72 69 73 |any dama|ges aris|
|00002c80| 69 6e 67 20 66 72 6f 6d | 20 73 61 6d 65 2e 0a 58 |ing from| same..X|
|00002c90| 20 2a 2f 0a 58 0a 58 23 | 69 66 6e 64 65 66 20 4e | */.X.X#|ifndef N|
|00002ca0| 55 4c 4c 0a 58 23 69 6e | 63 6c 75 64 65 20 3c 73 |ULL.X#in|clude <s|
|00002cb0| 74 64 69 6f 2e 68 3e 0a | 58 23 65 6e 64 69 66 0a |tdio.h>.|X#endif.|
|00002cc0| 58 0a 58 65 78 74 65 72 | 6e 20 63 68 61 72 20 2a |X.Xexter|n char *|
|00002cd0| 63 61 6c 6c 6f 63 28 29 | 3b 0a 58 23 69 66 64 65 |calloc()|;.X#ifde|
|00002ce0| 66 20 6c 69 6e 74 0a 58 | 23 64 65 66 69 6e 65 20 |f lint.X|#define |
|00002cf0| 43 41 4c 4c 4f 43 5f 4c | 49 4e 54 4f 4b 28 70 74 |CALLOC_L|INTOK(pt|
|00002d00| 72 2c 20 6e 65 6c 65 6d | 2c 20 74 79 70 65 29 20 |r, nelem|, type) |
|00002d10| 5c 0a 58 09 63 61 6c 6c | 6f 63 28 28 70 74 72 20 |\.X.call|oc((ptr |
|00002d20| 3d 20 28 74 79 70 65 20 | 2a 29 20 4e 55 4c 4c 2c |= (type |*) NULL,|
|00002d30| 20 28 75 6e 73 69 67 6e | 65 64 29 20 28 6e 65 6c | (unsign|ed) (nel|
|00002d40| 65 6d 29 29 2c 20 28 75 | 6e 73 69 67 6e 65 64 29 |em)), (u|nsigned)|
|00002d50| 20 73 69 7a 65 6f 66 28 | 74 79 70 65 29 29 0a 58 | sizeof(|type)).X|
|00002d60| 23 65 6c 73 65 0a 58 23 | 64 65 66 69 6e 65 20 43 |#else.X#|define C|
|00002d70| 41 4c 4c 4f 43 5f 4c 49 | 4e 54 4f 4b 28 70 74 72 |ALLOC_LI|NTOK(ptr|
|00002d80| 2c 20 6e 65 6c 65 6d 2c | 20 74 79 70 65 29 20 5c |, nelem,| type) \|
|00002d90| 0a 58 09 28 70 74 72 20 | 3d 20 28 74 79 70 65 20 |.X.(ptr |= (type |
|00002da0| 2a 29 20 63 61 6c 6c 6f | 63 28 28 75 6e 73 69 67 |*) callo|c((unsig|
|00002db0| 6e 65 64 29 20 28 6e 65 | 6c 65 6d 29 2c 20 28 75 |ned) (ne|lem), (u|
|00002dc0| 6e 73 69 67 6e 65 64 29 | 20 73 69 7a 65 6f 66 28 |nsigned)| sizeof(|
|00002dd0| 74 79 70 65 29 29 29 0a | 58 23 65 6e 64 69 66 0a |type))).|X#endif.|
|00002de0| 58 0a 58 65 78 74 65 72 | 6e 20 63 68 61 72 20 2a |X.Xexter|n char *|
|00002df0| 6d 61 6c 6c 6f 63 28 29 | 3b 0a 58 23 69 66 64 65 |malloc()|;.X#ifde|
|00002e00| 66 20 6c 69 6e 74 0a 58 | 23 64 65 66 69 6e 65 20 |f lint.X|#define |
|00002e10| 4d 41 4c 4c 4f 43 5f 4c | 49 4e 54 4f 4b 28 70 74 |MALLOC_L|INTOK(pt|
|00002e20| 72 2c 20 6e 65 6c 65 6d | 2c 20 74 79 70 65 29 20 |r, nelem|, type) |
|00002e30| 5c 0a 58 09 6d 61 6c 6c | 6f 63 28 28 70 74 72 20 |\.X.mall|oc((ptr |
|00002e40| 3d 20 28 74 79 70 65 20 | 2a 29 20 4e 55 4c 4c 2c |= (type |*) NULL,|
|00002e50| 20 28 75 6e 73 69 67 6e | 65 64 29 20 28 28 6e 65 | (unsign|ed) ((ne|
|00002e60| 6c 65 6d 29 20 2a 20 73 | 69 7a 65 6f 66 28 74 79 |lem) * s|izeof(ty|
|00002e70| 70 65 29 29 29 29 0a 58 | 23 65 6c 73 65 0a 58 23 |pe)))).X|#else.X#|
|00002e80| 64 65 66 69 6e 65 20 4d | 41 4c 4c 4f 43 5f 4c 49 |define M|ALLOC_LI|
|00002e90| 4e 54 4f 4b 28 70 74 72 | 2c 20 6e 65 6c 65 6d 2c |NTOK(ptr|, nelem,|
|00002ea0| 20 74 79 70 65 29 20 5c | 0a 58 09 28 70 74 72 20 | type) \|.X.(ptr |
|00002eb0| 3d 20 28 74 79 70 65 20 | 2a 29 20 6d 61 6c 6c 6f |= (type |*) mallo|
|00002ec0| 63 28 28 75 6e 73 69 67 | 6e 65 64 29 20 28 28 6e |c((unsig|ned) ((n|
|00002ed0| 65 6c 65 6d 29 20 2a 20 | 73 69 7a 65 6f 66 28 74 |elem) * |sizeof(t|
|00002ee0| 79 70 65 29 29 29 29 0a | 58 23 65 6e 64 69 66 0a |ype)))).|X#endif.|
|00002ef0| 58 0a 58 65 78 74 65 72 | 6e 20 63 68 61 72 20 2a |X.Xexter|n char *|
|00002f00| 72 65 61 6c 6c 6f 63 28 | 29 3b 0a 58 23 69 66 64 |realloc(|);.X#ifd|
|00002f10| 65 66 20 6c 69 6e 74 0a | 58 23 64 65 66 69 6e 65 |ef lint.|X#define|
|00002f20| 20 52 45 41 4c 4c 4f 43 | 5f 4c 49 4e 54 4f 4b 28 | REALLOC|_LINTOK(|
|00002f30| 70 74 72 2c 20 6e 65 6c | 65 6d 2c 20 74 79 70 65 |ptr, nel|em, type|
|00002f40| 29 20 5c 0a 58 09 72 65 | 61 6c 6c 6f 63 28 20 5c |) \.X.re|alloc( \|
|00002f50| 0a 58 09 09 28 70 74 72 | 20 3d 20 28 74 79 70 65 |.X..(ptr| = (type|
|00002f60| 20 2a 29 20 4e 55 4c 4c | 2c 20 28 63 68 61 72 20 | *) NULL|, (char |
|00002f70| 2a 29 20 4e 55 4c 4c 29 | 2c 20 5c 0a 58 09 09 28 |*) NULL)|, \.X..(|
|00002f80| 75 6e 73 69 67 6e 65 64 | 29 20 28 28 6e 65 6c 65 |unsigned|) ((nele|
|00002f90| 6d 29 20 2a 20 73 69 7a | 65 6f 66 28 74 79 70 65 |m) * siz|eof(type|
|00002fa0| 29 29 29 0a 58 23 65 6c | 73 65 0a 58 23 64 65 66 |))).X#el|se.X#def|
|00002fb0| 69 6e 65 20 52 45 41 4c | 4c 4f 43 5f 4c 49 4e 54 |ine REAL|LOC_LINT|
|00002fc0| 4f 4b 28 70 74 72 2c 20 | 6e 65 6c 65 6d 2c 20 74 |OK(ptr, |nelem, t|
|00002fd0| 79 70 65 29 20 5c 0a 58 | 09 28 70 74 72 20 3d 20 |ype) \.X|.(ptr = |
|00002fe0| 28 74 79 70 65 20 2a 29 | 20 72 65 61 6c 6c 6f 63 |(type *)| realloc|
|00002ff0| 28 20 5c 0a 58 09 09 28 | 63 68 61 72 20 2a 29 20 |( \.X..(|char *) |
|00003000| 70 74 72 2c 20 5c 0a 58 | 09 09 28 75 6e 73 69 67 |ptr, \.X|..(unsig|
|00003010| 6e 65 64 29 20 28 28 6e | 65 6c 65 6d 29 20 2a 20 |ned) ((n|elem) * |
|00003020| 73 69 7a 65 6f 66 28 74 | 79 70 65 29 29 29 29 0a |sizeof(t|ype)))).|
|00003030| 58 23 65 6e 64 69 66 0a | 58 0a 58 2f 2a 20 63 6f |X#endif.|X.X/* co|
|00003040| 6d 6d 6f 6e 20 75 73 65 | 20 6f 66 20 6d 61 6c 6c |mmon use| of mall|
|00003050| 6f 63 2f 72 65 61 6c 6c | 6f 63 20 2d 2d 20 75 73 |oc/reall|oc -- us|
|00003060| 65 20 69 74 20 6f 72 20 | 64 6f 6e 27 74 20 75 73 |e it or |don't us|
|00003070| 65 20 69 74 20 2a 2f 0a | 58 23 64 65 66 69 6e 65 |e it */.|X#define|
|00003080| 20 4d 52 5f 41 4c 4c 4f | 43 5f 4c 49 4e 54 4f 4b | MR_ALLO|C_LINTOK|
|00003090| 28 70 74 72 2c 20 6e 65 | 6c 65 6d 2c 20 74 79 70 |(ptr, ne|lem, typ|
|000030a0| 65 29 20 5c 0a 58 09 28 | 20 28 70 74 72 29 20 3d |e) \.X.(| (ptr) =|
|000030b0| 3d 20 4e 55 4c 4c 20 5c | 0a 58 09 09 3f 20 4d 41 |= NULL \|.X..? MA|
|000030c0| 4c 4c 4f 43 5f 4c 49 4e | 54 4f 4b 28 70 74 72 2c |LLOC_LIN|TOK(ptr,|
|000030d0| 20 28 6e 65 6c 65 6d 29 | 2c 20 74 79 70 65 29 20 | (nelem)|, type) |
|000030e0| 5c 0a 58 09 09 3a 20 52 | 45 41 4c 4c 4f 43 5f 4c |\.X..: R|EALLOC_L|
|000030f0| 49 4e 54 4f 4b 28 70 74 | 72 2c 20 28 6e 65 6c 65 |INTOK(pt|r, (nele|
|00003100| 6d 29 2c 20 74 79 70 65 | 29 20 29 0a 58 0a 58 2f |m), type|) ).X.X/|
|00003110| 2a 0a 58 20 2a 09 54 68 | 65 73 65 20 6e 65 78 74 |*.X *.Th|ese next|
|00003120| 20 6d 61 63 72 6f 73 20 | 69 6e 76 6f 6b 65 20 43 | macros |invoke C|
|00003130| 41 4c 4c 4f 43 5f 4c 49 | 4e 54 4f 4b 2c 20 4d 41 |ALLOC_LI|NTOK, MA|
|00003140| 4c 4c 4f 43 5f 4c 49 4e | 54 4f 4b 2c 20 52 45 41 |LLOC_LIN|TOK, REA|
|00003150| 4c 4c 4f 43 5f 4c 49 4e | 54 4f 4b 2c 0a 58 20 2a |LLOC_LIN|TOK,.X *|
|00003160| 09 61 6e 64 20 4d 52 5f | 41 4c 4c 4f 43 5f 4c 49 |.and MR_|ALLOC_LI|
|00003170| 4e 54 4f 4b 20 77 69 74 | 68 20 61 6e 20 65 72 72 |NTOK wit|h an err|
|00003180| 6f 72 20 65 78 69 74 20 | 69 66 20 74 68 65 79 20 |or exit |if they |
|00003190| 66 61 69 6c 2e 0a 58 20 | 2a 0a 58 20 2a 09 49 66 |fail..X |*.X *.If|
|000031a0| 20 79 6f 75 20 77 61 6e | 74 20 74 6f 20 68 61 6e | you wan|t to han|
|000031b0| 64 6c 65 20 79 6f 75 72 | 20 6f 77 6e 20 6d 65 6d |dle your| own mem|
|000031c0| 6f 72 79 20 61 6c 6c 6f | 63 61 74 69 6f 6e 20 65 |ory allo|cation e|
|000031d0| 72 72 6f 72 73 2c 20 6a | 75 73 74 0a 58 20 2a 09 |rrors, j|ust.X *.|
|000031e0| 22 23 75 6e 64 65 66 20 | 45 52 52 4f 52 5f 45 58 |"#undef |ERROR_EX|
|000031f0| 49 54 5f 4c 49 4e 54 4f | 4b 22 20 61 6e 64 20 64 |IT_LINTO|K" and d|
|00003200| 65 66 69 6e 65 20 79 6f | 75 72 20 6f 77 6e 2e 0a |efine yo|ur own..|
|00003210| 58 20 2a 2f 0a 58 23 64 | 65 66 69 6e 65 20 45 52 |X */.X#d|efine ER|
|00003220| 52 4f 52 5f 45 58 49 54 | 5f 4c 49 4e 54 4f 4b 28 |ROR_EXIT|_LINTOK(|
|00003230| 6e 65 6c 65 6d 2c 20 73 | 69 7a 65 29 20 5c 0a 58 |nelem, s|ize) \.X|
|00003240| 09 7b 20 5c 0a 58 09 09 | 28 76 6f 69 64 29 20 66 |.{ \.X..|(void) f|
|00003250| 70 72 69 6e 74 66 28 73 | 74 64 65 72 72 2c 20 5c |printf(s|tderr, \|
|00003260| 0a 58 09 09 09 22 4d 65 | 6d 6f 72 79 20 61 6c 6c |.X..."Me|mory all|
|00003270| 6f 63 61 74 69 6f 6e 20 | 6f 66 20 25 64 20 2a 20 |ocation |of %d * |
|00003280| 25 64 20 62 79 74 65 73 | 20 6f 6e 20 6c 69 6e 65 |%d bytes| on line|
|00003290| 20 25 64 20 6f 66 20 5c | 22 25 73 5c 22 20 66 61 | %d of \|"%s\" fa|
|000032a0| 69 6c 65 64 2e 5c 6e 22 | 2c 20 5c 0a 58 09 09 09 |iled.\n"|, \.X...|
|000032b0| 28 6e 65 6c 65 6d 29 2c | 20 28 73 69 7a 65 29 2c |(nelem),| (size),|
|000032c0| 20 5f 5f 4c 49 4e 45 5f | 5f 2c 20 5f 5f 46 49 4c | __LINE_|_, __FIL|
|000032d0| 45 5f 5f 29 3b 20 5c 0a | 58 09 09 65 78 69 74 28 |E__); \.|X..exit(|
|000032e0| 31 29 3b 20 5c 0a 58 09 | 7d 0a 58 0a 58 23 64 65 |1); \.X.|}.X.X#de|
|000032f0| 66 69 6e 65 20 43 41 4c | 4c 4f 43 5f 4f 52 5f 45 |fine CAL|LOC_OR_E|
|00003300| 4c 53 45 5f 4c 49 4e 54 | 4f 4b 28 70 74 72 2c 20 |LSE_LINT|OK(ptr, |
|00003310| 6e 65 6c 65 6d 2c 20 74 | 79 70 65 29 20 5c 0a 58 |nelem, t|ype) \.X|
|00003320| 09 7b 20 5c 0a 58 09 09 | 69 66 20 28 43 41 4c 4c |.{ \.X..|if (CALL|
|00003330| 4f 43 5f 4c 49 4e 54 4f | 4b 28 70 74 72 2c 20 28 |OC_LINTO|K(ptr, (|
|00003340| 6e 65 6c 65 6d 29 2c 20 | 74 79 70 65 29 20 3d 3d |nelem), |type) ==|
|00003350| 20 4e 55 4c 4c 29 20 5c | 0a 58 09 09 09 45 52 52 | NULL) \|.X...ERR|
|00003360| 4f 52 5f 45 58 49 54 5f | 4c 49 4e 54 4f 4b 28 28 |OR_EXIT_|LINTOK((|
|00003370| 6e 65 6c 65 6d 29 2c 20 | 73 69 7a 65 6f 66 28 74 |nelem), |sizeof(t|
|00003380| 79 70 65 29 29 3b 20 5c | 0a 58 09 7d 0a 58 0a 58 |ype)); \|.X.}.X.X|
|00003390| 23 64 65 66 69 6e 65 20 | 4d 41 4c 4c 4f 43 5f 4f |#define |MALLOC_O|
|000033a0| 52 5f 45 4c 53 45 5f 4c | 49 4e 54 4f 4b 28 70 74 |R_ELSE_L|INTOK(pt|
|000033b0| 72 2c 20 6e 65 6c 65 6d | 2c 20 74 79 70 65 29 20 |r, nelem|, type) |
|000033c0| 5c 0a 58 09 7b 20 5c 0a | 58 09 09 69 66 20 28 4d |\.X.{ \.|X..if (M|
|000033d0| 41 4c 4c 4f 43 5f 4c 49 | 4e 54 4f 4b 28 70 74 72 |ALLOC_LI|NTOK(ptr|
|000033e0| 2c 20 28 6e 65 6c 65 6d | 29 2c 20 74 79 70 65 29 |, (nelem|), type)|
|000033f0| 20 3d 3d 20 4e 55 4c 4c | 29 20 5c 0a 58 09 09 09 | == NULL|) \.X...|
|00003400| 45 52 52 4f 52 5f 45 58 | 49 54 5f 4c 49 4e 54 4f |ERROR_EX|IT_LINTO|
|00003410| 4b 28 28 6e 65 6c 65 6d | 29 2c 20 73 69 7a 65 6f |K((nelem|), sizeo|
|00003420| 66 28 74 79 70 65 29 29 | 3b 20 5c 0a 58 09 7d 0a |f(type))|; \.X.}.|
|00003430| 58 0a 58 23 64 65 66 69 | 6e 65 20 52 45 41 4c 4c |X.X#defi|ne REALL|
|00003440| 4f 43 5f 4f 52 5f 45 4c | 53 45 5f 4c 49 4e 54 4f |OC_OR_EL|SE_LINTO|
|00003450| 4b 28 70 74 72 2c 20 6e | 65 6c 65 6d 2c 20 74 79 |K(ptr, n|elem, ty|
|00003460| 70 65 29 20 5c 0a 58 09 | 7b 20 5c 0a 58 09 09 69 |pe) \.X.|{ \.X..i|
|00003470| 66 20 28 52 45 41 4c 4c | 4f 43 5f 4c 49 4e 54 4f |f (REALL|OC_LINTO|
|00003480| 4b 28 70 74 72 2c 20 28 | 6e 65 6c 65 6d 29 2c 20 |K(ptr, (|nelem), |
|00003490| 74 79 70 65 29 20 3d 3d | 20 4e 55 4c 4c 29 20 5c |type) ==| NULL) \|
|000034a0| 0a 58 09 09 09 45 52 52 | 4f 52 5f 45 58 49 54 5f |.X...ERR|OR_EXIT_|
|000034b0| 4c 49 4e 54 4f 4b 28 28 | 6e 65 6c 65 6d 29 2c 20 |LINTOK((|nelem), |
|000034c0| 73 69 7a 65 6f 66 28 74 | 79 70 65 29 29 3b 20 5c |sizeof(t|ype)); \|
|000034d0| 0a 58 09 7d 0a 58 0a 58 | 23 64 65 66 69 6e 65 20 |.X.}.X.X|#define |
|000034e0| 4d 52 5f 41 4c 4c 4f 43 | 5f 4f 52 5f 45 4c 53 45 |MR_ALLOC|_OR_ELSE|
|000034f0| 5f 4c 49 4e 54 4f 4b 28 | 70 74 72 2c 20 6e 65 6c |_LINTOK(|ptr, nel|
|00003500| 65 6d 2c 20 74 79 70 65 | 29 20 5c 0a 58 09 7b 20 |em, type|) \.X.{ |
|00003510| 5c 0a 58 09 09 69 66 20 | 28 4d 52 5f 41 4c 4c 4f |\.X..if |(MR_ALLO|
|00003520| 43 5f 4c 49 4e 54 4f 4b | 28 70 74 72 2c 20 28 6e |C_LINTOK|(ptr, (n|
|00003530| 65 6c 65 6d 29 2c 20 74 | 79 70 65 29 20 3d 3d 20 |elem), t|ype) == |
|00003540| 4e 55 4c 4c 29 20 5c 0a | 58 09 09 09 45 52 52 4f |NULL) \.|X...ERRO|
|00003550| 52 5f 45 58 49 54 5f 4c | 49 4e 54 4f 4b 28 28 6e |R_EXIT_L|INTOK((n|
|00003560| 65 6c 65 6d 29 2c 20 73 | 69 7a 65 6f 66 28 74 79 |elem), s|izeof(ty|
|00003570| 70 65 29 29 3b 20 5c 0a | 58 09 7d 0a 58 0a 58 65 |pe)); \.|X.}.X.Xe|
|00003580| 78 74 65 72 6e 20 66 72 | 65 65 28 29 3b 0a 58 23 |xtern fr|ee();.X#|
|00003590| 69 66 64 65 66 20 6c 69 | 6e 74 0a 58 23 64 65 66 |ifdef li|nt.X#def|
|000035a0| 69 6e 65 20 46 52 45 45 | 5f 4c 49 4e 54 4f 4b 28 |ine FREE|_LINTOK(|
|000035b0| 70 74 72 29 20 5c 0a 58 | 09 66 72 65 65 28 28 70 |ptr) \.X|.free((p|
|000035c0| 74 72 20 3d 20 4e 55 4c | 4c 2c 20 28 63 68 61 72 |tr = NUL|L, (char|
|000035d0| 20 2a 29 20 4e 55 4c 4c | 29 29 0a 58 23 65 6c 73 | *) NULL|)).X#els|
|000035e0| 65 0a 58 23 64 65 66 69 | 6e 65 20 46 52 45 45 5f |e.X#defi|ne FREE_|
|000035f0| 4c 49 4e 54 4f 4b 28 70 | 74 72 29 20 5c 0a 58 09 |LINTOK(p|tr) \.X.|
|00003600| 66 72 65 65 28 28 63 68 | 61 72 20 2a 29 20 70 74 |free((ch|ar *) pt|
|00003610| 72 29 0a 58 23 65 6e 64 | 69 66 0a 58 0a 58 2f 2a |r).X#end|if.X.X/*|
|00003620| 20 57 65 20 63 6f 75 6c | 64 20 68 61 76 65 20 61 | We coul|d have a|
|00003630| 20 22 43 46 52 45 45 5f | 4c 49 4e 54 4f 4b 22 2c | "CFREE_|LINTOK",|
|00003640| 20 62 75 74 20 77 68 61 | 74 27 73 20 74 68 65 20 | but wha|t's the |
|00003650| 70 6f 69 6e 74 3f 20 2a | 2f 0a 58 0a 58 23 64 65 |point? *|/.X.X#de|
|00003660| 66 69 6e 65 20 49 4e 43 | 4c 55 44 45 44 5f 4c 49 |fine INC|LUDED_LI|
|00003670| 4e 54 4f 4b 0a 58 23 65 | 6e 64 69 66 0a 58 0a 45 |NTOK.X#e|ndif.X.E|
|00003680| 4e 44 5f 4f 46 5f 6d 65 | 6d 6c 69 6e 74 6f 6b 2e |ND_OF_me|mlintok.|
|00003690| 68 0a 69 66 20 74 65 73 | 74 20 32 39 38 36 20 2d |h.if tes|t 2986 -|
|000036a0| 6e 65 20 60 77 63 20 2d | 63 20 3c 6d 65 6d 6c 69 |ne `wc -|c <memli|
|000036b0| 6e 74 6f 6b 2e 68 60 3b | 20 74 68 65 6e 0a 20 20 |ntok.h`;| then. |
|000036c0| 20 20 65 63 68 6f 20 73 | 68 61 72 3a 20 5c 22 6d | echo s|har: \"m|
|000036d0| 65 6d 6c 69 6e 74 6f 6b | 2e 68 5c 22 20 75 6e 70 |emlintok|.h\" unp|
|000036e0| 61 63 6b 65 64 20 77 69 | 74 68 20 77 72 6f 6e 67 |acked wi|th wrong|
|000036f0| 20 73 69 7a 65 21 0a 66 | 69 0a 23 20 65 6e 64 20 | size!.f|i.# end |
|00003700| 6f 66 20 6f 76 65 72 77 | 72 69 74 69 6e 67 20 63 |of overw|riting c|
|00003710| 68 65 63 6b 0a 66 69 0a | 69 66 20 74 65 73 74 20 |heck.fi.|if test |
|00003720| 2d 66 20 74 5f 6d 65 6d | 6c 69 6e 74 6f 6b 2e 63 |-f t_mem|lintok.c|
|00003730| 20 2d 61 20 22 24 7b 31 | 7d 22 20 21 3d 20 22 2d | -a "${1|}" != "-|
|00003740| 63 22 20 3b 20 74 68 65 | 6e 20 0a 20 20 65 63 68 |c" ; the|n . ech|
|00003750| 6f 20 73 68 61 72 3a 20 | 57 69 6c 6c 20 6e 6f 74 |o shar: |Will not|
|00003760| 20 6f 76 65 72 2d 77 72 | 69 74 65 20 65 78 69 73 | over-wr|ite exis|
|00003770| 74 69 6e 67 20 66 69 6c | 65 20 5c 22 74 5f 6d 65 |ting fil|e \"t_me|
|00003780| 6d 6c 69 6e 74 6f 6b 2e | 63 5c 22 0a 65 6c 73 65 |mlintok.|c\".else|
|00003790| 0a 65 63 68 6f 20 73 68 | 61 72 3a 20 45 78 74 72 |.echo sh|ar: Extr|
|000037a0| 61 63 74 69 6e 67 20 5c | 22 74 5f 6d 65 6d 6c 69 |acting \|"t_memli|
|000037b0| 6e 74 6f 6b 2e 63 5c 22 | 20 5c 28 31 34 33 38 20 |ntok.c\"| \(1438 |
|000037c0| 63 68 61 72 61 63 74 65 | 72 73 5c 29 0a 73 65 64 |characte|rs\).sed|
|000037d0| 20 22 73 2f 5e 58 2f 2f | 22 20 3e 74 5f 6d 65 6d | "s/^X//|" >t_mem|
|000037e0| 6c 69 6e 74 6f 6b 2e 63 | 20 3c 3c 27 45 4e 44 5f |lintok.c| <<'END_|
|000037f0| 4f 46 5f 74 5f 6d 65 6d | 6c 69 6e 74 6f 6b 2e 63 |OF_t_mem|lintok.c|
|00003800| 27 0a 58 2f 2a 20 24 48 | 65 61 64 65 72 3a 20 74 |'.X/* $H|eader: t|
|00003810| 5f 6d 65 6d 6c 69 6e 74 | 6f 6b 2e 63 2c 76 20 31 |_memlint|ok.c,v 1|
|00003820| 2e 33 20 38 39 2f 30 35 | 2f 30 32 20 31 35 3a 30 |.3 89/05|/02 15:0|
|00003830| 37 3a 30 38 20 62 6f 62 | 6c 20 45 78 70 20 24 20 |7:08 bob|l Exp $ |
|00003840| 2a 2f 0a 58 0a 58 23 69 | 6e 63 6c 75 64 65 20 3c |*/.X.X#i|nclude <|
|00003850| 73 74 64 69 6f 2e 68 3e | 0a 58 0a 58 23 69 6e 63 |stdio.h>|.X.X#inc|
|00003860| 6c 75 64 65 20 22 6d 65 | 6d 6c 69 6e 74 6f 6b 2e |lude "me|mlintok.|
|00003870| 68 22 0a 58 0a 58 6d 61 | 69 6e 28 29 0a 58 7b 0a |h".X.Xma|in().X{.|
|00003880| 58 09 69 6e 74 20 2a 70 | 2c 20 2a 71 3b 0a 58 0a |X.int *p|, *q;.X.|
|00003890| 58 09 69 66 20 28 4d 41 | 4c 4c 4f 43 5f 4c 49 4e |X.if (MA|LLOC_LIN|
|000038a0| 54 4f 4b 28 70 2c 20 31 | 30 30 2c 20 69 6e 74 29 |TOK(p, 1|00, int)|
|000038b0| 20 3d 3d 20 4e 55 4c 4c | 29 0a 58 09 09 66 61 69 | == NULL|).X..fai|
|000038c0| 6c 28 22 63 61 6e 27 74 | 20 6d 61 6c 6c 6f 63 20 |l("can't| malloc |
|000038d0| 31 30 30 20 69 6e 74 73 | 5c 6e 22 29 3b 0a 58 09 |100 ints|\n");.X.|
|000038e0| 65 6c 73 65 0a 58 09 09 | 73 75 63 63 65 65 64 28 |else.X..|succeed(|
|000038f0| 22 31 30 30 20 69 6e 74 | 73 20 6d 61 6c 6c 6f 63 |"100 int|s malloc|
|00003900| 27 64 5c 6e 22 29 3b 0a | 58 0a 58 09 28 76 6f 69 |'d\n");.|X.X.(voi|
|00003910| 64 29 20 52 45 41 4c 4c | 4f 43 5f 4c 49 4e 54 4f |d) REALL|OC_LINTO|
|00003920| 4b 28 70 2c 20 32 30 30 | 2c 20 69 6e 74 29 3b 0a |K(p, 200|, int);.|
|00003930| 58 09 69 66 20 28 70 20 | 3d 3d 20 4e 55 4c 4c 29 |X.if (p |== NULL)|
|00003940| 0a 58 09 09 66 61 69 6c | 28 22 63 61 6e 27 74 20 |.X..fail|("can't |
|00003950| 72 65 61 6c 6c 6f 63 20 | 32 30 30 20 69 6e 74 73 |realloc |200 ints|
|00003960| 5c 6e 22 29 3b 0a 58 09 | 65 6c 73 65 0a 58 09 09 |\n");.X.|else.X..|
|00003970| 73 75 63 63 65 65 64 28 | 22 32 30 30 20 69 6e 74 |succeed(|"200 int|
|00003980| 73 20 72 65 61 6c 6c 6f | 63 27 64 5c 6e 22 29 3b |s reallo|c'd\n");|
|00003990| 0a 58 0a 58 09 69 66 20 | 28 4d 52 5f 41 4c 4c 4f |.X.X.if |(MR_ALLO|
|000039a0| 43 5f 4c 49 4e 54 4f 4b | 28 70 2c 20 32 35 2c 20 |C_LINTOK|(p, 25, |
|000039b0| 69 6e 74 29 20 3d 3d 20 | 4e 55 4c 4c 29 0a 58 09 |int) == |NULL).X.|
|000039c0| 09 66 61 69 6c 28 22 63 | 61 6e 27 74 20 6d 72 5f |.fail("c|an't mr_|
|000039d0| 61 6c 6c 6f 63 20 28 72 | 65 61 6c 6c 6f 63 29 20 |alloc (r|ealloc) |
|000039e0| 32 35 20 69 6e 74 73 5c | 6e 22 29 3b 0a 58 09 65 |25 ints\|n");.X.e|
|000039f0| 6c 73 65 0a 58 09 09 73 | 75 63 63 65 65 64 28 22 |lse.X..s|ucceed("|
|00003a00| 32 35 20 69 6e 74 73 20 | 6d 72 5f 61 6c 6c 6f 63 |25 ints |mr_alloc|
|00003a10| 27 64 20 28 72 65 61 6c | 6c 6f 63 27 64 29 5c 6e |'d (real|loc'd)\n|
|00003a20| 22 29 3b 0a 58 0a 58 09 | 69 66 20 28 43 41 4c 4c |");.X.X.|if (CALL|
|00003a30| 4f 43 5f 4c 49 4e 54 4f | 4b 28 71 2c 20 35 30 30 |OC_LINTO|K(q, 500|
|00003a40| 2c 20 69 6e 74 29 20 3d | 3d 20 4e 55 4c 4c 29 0a |, int) =|= NULL).|
|00003a50| 58 09 09 66 61 69 6c 28 | 22 63 61 6e 27 74 20 63 |X..fail(|"can't c|
|00003a60| 61 6c 6c 6f 63 20 35 30 | 30 20 69 6e 74 73 5c 6e |alloc 50|0 ints\n|
|00003a70| 22 29 3b 0a 58 09 65 6c | 73 65 0a 58 09 09 73 75 |");.X.el|se.X..su|
|00003a80| 63 63 65 65 64 28 22 35 | 30 30 20 69 6e 74 73 20 |cceed("5|00 ints |
|00003a90| 63 61 6c 6c 6f 63 27 64 | 5c 6e 22 29 3b 0a 58 09 |calloc'd|\n");.X.|
|00003aa0| 71 5b 30 5d 20 3d 20 30 | 3b 0a 58 09 46 52 45 45 |q[0] = 0|;.X.FREE|
|00003ab0| 5f 4c 49 4e 54 4f 4b 28 | 71 29 3b 0a 58 0a 58 09 |_LINTOK(|q);.X.X.|
|00003ac0| 46 52 45 45 5f 4c 49 4e | 54 4f 4b 28 70 29 3b 0a |FREE_LIN|TOK(p);.|
|00003ad0| 58 09 70 20 3d 20 4e 55 | 4c 4c 3b 0a 58 09 69 66 |X.p = NU|LL;.X.if|
|00003ae0| 20 28 4d 52 5f 41 4c 4c | 4f 43 5f 4c 49 4e 54 4f | (MR_ALL|OC_LINTO|
|00003af0| 4b 28 70 2c 20 31 30 30 | 30 2c 20 69 6e 74 29 20 |K(p, 100|0, int) |
|00003b00| 3d 3d 20 4e 55 4c 4c 29 | 0a 58 09 09 66 61 69 6c |== NULL)|.X..fail|
|00003b10| 28 22 63 61 6e 27 74 20 | 6d 72 5f 61 6c 6c 6f 63 |("can't |mr_alloc|
|00003b20| 20 28 6d 61 6c 6c 6f 63 | 29 20 31 30 30 30 20 69 | (malloc|) 1000 i|
|00003b30| 6e 74 73 5c 6e 22 29 3b | 0a 58 09 65 6c 73 65 0a |nts\n");|.X.else.|
|00003b40| 58 09 09 73 75 63 63 65 | 65 64 28 22 31 30 30 30 |X..succe|ed("1000|
|00003b50| 20 69 6e 74 73 20 6d 72 | 5f 61 6c 6c 6f 63 27 64 | ints mr|_alloc'd|
|00003b60| 20 28 6d 61 6c 6c 6f 63 | 27 64 29 5c 6e 22 29 3b | (malloc|'d)\n");|
|00003b70| 0a 58 0a 58 09 43 41 4c | 4c 4f 43 5f 4f 52 5f 45 |.X.X.CAL|LOC_OR_E|
|00003b80| 4c 53 45 5f 4c 49 4e 54 | 4f 4b 28 70 2c 20 35 30 |LSE_LINT|OK(p, 50|
|00003b90| 2c 20 69 6e 74 29 3b 0a | 58 09 73 75 63 63 65 65 |, int);.|X.succee|
|00003ba0| 64 28 22 35 30 20 69 6e | 74 73 20 63 61 6c 6c 6f |d("50 in|ts callo|
|00003bb0| 63 27 64 20 28 6f 72 20 | 65 6c 73 65 29 5c 6e 22 |c'd (or |else)\n"|
|00003bc0| 29 3b 0a 58 09 4d 41 4c | 4c 4f 43 5f 4f 52 5f 45 |);.X.MAL|LOC_OR_E|
|00003bd0| 4c 53 45 5f 4c 49 4e 54 | 4f 4b 28 70 2c 20 31 30 |LSE_LINT|OK(p, 10|
|00003be0| 30 2c 20 69 6e 74 29 3b | 0a 58 09 73 75 63 63 65 |0, int);|.X.succe|
|00003bf0| 65 64 28 22 31 30 30 20 | 69 6e 74 73 20 6d 61 6c |ed("100 |ints mal|
|00003c00| 6c 6f 63 27 64 20 28 6f | 72 20 65 6c 73 65 29 5c |loc'd (o|r else)\|
|00003c10| 6e 22 29 3b 0a 58 09 52 | 45 41 4c 4c 4f 43 5f 4f |n");.X.R|EALLOC_O|
|00003c20| 52 5f 45 4c 53 45 5f 4c | 49 4e 54 4f 4b 28 70 2c |R_ELSE_L|INTOK(p,|
|00003c30| 20 32 30 30 2c 20 69 6e | 74 29 3b 0a 58 09 73 75 | 200, in|t);.X.su|
|00003c40| 63 63 65 65 64 28 22 32 | 30 30 20 69 6e 74 73 20 |cceed("2|00 ints |
|00003c50| 72 65 61 6c 6c 6f 63 27 | 64 20 28 6f 72 20 65 6c |realloc'|d (or el|
|00003c60| 73 65 29 5c 6e 22 29 3b | 0a 58 0a 58 23 75 6e 64 |se)\n");|.X.X#und|
|00003c70| 65 66 20 45 52 52 4f 52 | 5f 45 58 49 54 5f 4c 49 |ef ERROR|_EXIT_LI|
|00003c80| 4e 54 4f 4b 0a 58 23 64 | 65 66 69 6e 65 20 45 52 |NTOK.X#d|efine ER|
|00003c90| 52 4f 52 5f 45 58 49 54 | 5f 4c 49 4e 54 4f 4b 28 |ROR_EXIT|_LINTOK(|
|00003ca0| 6e 65 6c 65 6d 2c 20 73 | 69 7a 65 29 20 5c 0a 58 |nelem, s|ize) \.X|
|00003cb0| 09 66 61 69 6c 28 22 6d | 65 6d 6f 72 79 20 61 6c |.fail("m|emory al|
|00003cc0| 6c 6f 63 61 74 69 6f 6e | 20 66 61 69 6c 65 64 5c |location| failed\|
|00003cd0| 6e 22 29 3b 0a 58 0a 58 | 09 4d 52 5f 41 4c 4c 4f |n");.X.X|.MR_ALLO|
|00003ce0| 43 5f 4f 52 5f 45 4c 53 | 45 5f 4c 49 4e 54 4f 4b |C_OR_ELS|E_LINTOK|
|00003cf0| 28 70 2c 20 34 30 30 2c | 20 69 6e 74 29 3b 0a 58 |(p, 400,| int);.X|
|00003d00| 09 73 75 63 63 65 65 64 | 28 22 34 30 30 20 69 6e |.succeed|("400 in|
|00003d10| 74 73 20 6d 72 5f 61 6c | 6c 6f 63 27 64 20 28 72 |ts mr_al|loc'd (r|
|00003d20| 65 61 6c 6c 6f 63 27 64 | 29 20 28 6f 72 20 65 6c |ealloc'd|) (or el|
|00003d30| 73 65 29 5c 6e 22 29 3b | 0a 58 0a 58 09 65 78 69 |se)\n");|.X.X.exi|
|00003d40| 74 28 30 29 3b 0a 58 09 | 72 65 74 75 72 6e 20 30 |t(0);.X.|return 0|
|00003d50| 3b 09 2f 2a 20 73 68 75 | 74 73 20 75 70 20 48 50 |;./* shu|ts up HP|
|00003d60| 2d 55 58 20 6c 69 6e 74 | 20 2a 2f 0a 58 7d 0a 58 |-UX lint| */.X}.X|
|00003d70| 0a 58 66 61 69 6c 28 73 | 29 0a 58 09 63 68 61 72 |.Xfail(s|).X.char|
|00003d80| 20 2a 73 3b 0a 58 7b 0a | 58 09 66 70 75 74 73 28 | *s;.X{.|X.fputs(|
|00003d90| 73 2c 20 73 74 64 6f 75 | 74 29 3b 0a 58 09 65 78 |s, stdou|t);.X.ex|
|00003da0| 69 74 28 31 29 3b 0a 58 | 7d 0a 58 0a 58 73 75 63 |it(1);.X|}.X.Xsuc|
|00003db0| 63 65 65 64 28 73 29 0a | 58 09 63 68 61 72 20 2a |ceed(s).|X.char *|
|00003dc0| 73 3b 0a 58 7b 0a 58 09 | 66 70 75 74 73 28 73 2c |s;.X{.X.|fputs(s,|
|00003dd0| 20 73 74 64 6f 75 74 29 | 3b 0a 58 09 72 65 74 75 | stdout)|;.X.retu|
|00003de0| 72 6e 3b 0a 58 7d 0a 45 | 4e 44 5f 4f 46 5f 74 5f |rn;.X}.E|ND_OF_t_|
|00003df0| 6d 65 6d 6c 69 6e 74 6f | 6b 2e 63 0a 69 66 20 74 |memlinto|k.c.if t|
|00003e00| 65 73 74 20 31 34 33 38 | 20 2d 6e 65 20 60 77 63 |est 1438| -ne `wc|
|00003e10| 20 2d 63 20 3c 74 5f 6d | 65 6d 6c 69 6e 74 6f 6b | -c <t_m|emlintok|
|00003e20| 2e 63 60 3b 20 74 68 65 | 6e 0a 20 20 20 20 65 63 |.c`; the|n. ec|
|00003e30| 68 6f 20 73 68 61 72 3a | 20 5c 22 74 5f 6d 65 6d |ho shar:| \"t_mem|
|00003e40| 6c 69 6e 74 6f 6b 2e 63 | 5c 22 20 75 6e 70 61 63 |lintok.c|\" unpac|
|00003e50| 6b 65 64 20 77 69 74 68 | 20 77 72 6f 6e 67 20 73 |ked with| wrong s|
|00003e60| 69 7a 65 21 0a 66 69 0a | 23 20 65 6e 64 20 6f 66 |ize!.fi.|# end of|
|00003e70| 20 6f 76 65 72 77 72 69 | 74 69 6e 67 20 63 68 65 | overwri|ting che|
|00003e80| 63 6b 0a 66 69 0a 65 63 | 68 6f 20 73 68 61 72 3a |ck.fi.ec|ho shar:|
|00003e90| 20 45 6e 64 20 6f 66 20 | 73 68 65 6c 6c 20 61 72 | End of |shell ar|
|00003ea0| 63 68 69 76 65 2e 0a 65 | 78 69 74 20 30 0a 0a 2d |chive..e|xit 0..-|
|00003eb0| 2d 20 0a 50 6c 65 61 73 | 65 20 73 65 6e 64 20 63 |- .Pleas|e send c|
|00003ec0| 6f 6d 70 2e 73 6f 75 72 | 63 65 73 2e 75 6e 69 78 |omp.sour|ces.unix|
|00003ed0| 2d 72 65 6c 61 74 65 64 | 20 6d 61 69 6c 20 74 6f |-related| mail to|
|00003ee0| 20 72 73 61 6c 7a 40 75 | 75 6e 65 74 2e 75 75 2e | rsalz@u|unet.uu.|
|00003ef0| 6e 65 74 2e 0a 55 73 65 | 20 61 20 64 6f 6d 61 69 |net..Use| a domai|
|00003f00| 6e 2d 62 61 73 65 64 20 | 61 64 64 72 65 73 73 20 |n-based |address |
|00003f10| 6f 72 20 67 69 76 65 20 | 61 6c 74 65 72 6e 61 74 |or give |alternat|
|00003f20| 65 20 70 61 74 68 73 2c | 20 6f 72 20 79 6f 75 20 |e paths,| or you |
|00003f30| 6d 61 79 20 6c 6f 73 65 | 20 6f 75 74 2e 0a |may lose| out.. |
+--------+-------------------------+-------------------------+--------+--------+