home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume20 / memlintok < prev    next >
SHell self-extracting ARchive  |  1989-10-26  |  15.5 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


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

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 or mail, ASCII text default
100% checkBytes Printable ASCII 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/rfc822 default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 53 75 62 6a 65 63 74 3a | 20 20 76 32 30 69 30 37 |Subject:| v20i07|
|00000010| 37 3a 20 20 41 20 70 61 | 63 6b 61 67 65 20 74 6f |7: A pa|ckage to|
|00000020| 20 72 65 6d 6f 76 65 20 | 63 6f 6d 6d 6f 6e 20 6c | remove |common l|
|00000030| 69 6e 74 2f 6d 61 6c 6c | 6f 63 20 63 6f 6d 70 6c |int/mall|oc compl|
|00000040| 61 69 6e 74 73 0a 4e 65 | 77 73 67 72 6f 75 70 73 |aints.Ne|wsgroups|
|00000050| 3a 20 63 6f 6d 70 2e 73 | 6f 75 72 63 65 73 2e 75 |: comp.s|ources.u|
|00000060| 6e 69 78 0a 53 65 6e 64 | 65 72 3a 20 73 6f 75 72 |nix.Send|er: sour|
|00000070| 63 65 73 0a 41 70 70 72 | 6f 76 65 64 3a 20 72 73 |ces.Appr|oved: rs|
|00000080| 61 6c 7a 40 75 75 6e 65 | 74 2e 55 55 2e 4e 45 54 |alz@uune|t.UU.NET|
|00000090| 0a 0a 53 75 62 6d 69 74 | 74 65 64 2d 62 79 3a 20 |..Submit|ted-by: |
|000000a0| 42 6f 62 20 4c 65 77 69 | 73 20 3c 75 75 6e 65 74 |Bob Lewi|s <uunet|
|000000b0| 21 74 65 73 73 69 21 62 | 6f 62 6c 3e 0a 50 6f 73 |!tessi!b|obl>.Pos|
|000000c0| 74 69 6e 67 2d 6e 75 6d | 62 65 72 3a 20 56 6f 6c |ting-num|ber: Vol|
|000000d0| 75 6d 65 20 32 30 2c 20 | 49 73 73 75 65 20 37 37 |ume 20, |Issue 77|
|000000e0| 0a 41 72 63 68 69 76 65 | 2d 6e 61 6d 65 3a 20 6d |.Archive|-name: m|
|000000f0| 65 6d 6c 69 6e 74 6f 6b | 0a 0a 5b 20 20 56 61 72 |emlintok|..[ Var|
|00000100| 69 6f 75 73 20 74 6f 6f | 6c 73 20 61 6e 64 20 74 |ious too|ls and t|
|00000110| 72 69 63 6b 73 20 66 6f | 72 20 64 6f 69 6e 67 20 |ricks fo|r doing |
|00000120| 74 68 69 73 20 61 62 6f | 75 6e 64 3b 20 6d 69 67 |this abo|und; mig|
|00000130| 68 74 20 61 73 20 77 65 | 6c 6c 20 67 65 74 20 6f |ht as we|ll get o|
|00000140| 6e 65 0a 20 20 20 69 6e | 20 74 68 65 20 61 72 63 |ne. in| the arc|
|00000150| 68 69 76 65 73 2e 20 20 | 50 6c 65 61 73 65 20 64 |hives. |Please d|
|00000160| 6f 6e 27 74 20 73 75 62 | 6d 69 74 20 61 6e 79 20 |on't sub|mit any |
|00000170| 6f 74 68 65 72 73 20 75 | 6e 6c 65 73 73 20 74 68 |others u|nless th|
|00000180| 65 79 27 72 65 0a 20 20 | 20 73 69 67 6e 69 66 69 |ey're. | signifi|
|00000190| 63 61 6e 74 6c 79 20 62 | 65 74 74 65 72 20 6f 72 |cantly b|etter or|
|000001a0| 20 64 69 66 66 65 72 65 | 6e 74 2e 20 20 2f 72 24 | differe|nt. /r$|
|000001b0| 20 20 5d 0a 0a 22 6d 65 | 6d 6c 69 6e 74 6f 6b 2e | ].."me|mlintok.|
|000001c0| 68 22 20 69 73 20 61 20 | 68 65 61 64 65 72 20 66 |h" is a |header f|
|000001d0| 69 6c 65 20 74 68 61 74 | 20 63 61 6e 20 62 65 20 |ile that| can be |
|000001e0| 75 73 65 64 20 74 6f 20 | 70 6f 6c 69 74 65 6c 79 |used to |politely|
|000001f0| 20 73 68 75 74 20 6c 69 | 6e 74 28 31 29 0a 75 70 | shut li|nt(1).up|
|00000200| 20 61 62 6f 75 74 20 63 | 61 73 74 69 6e 67 20 72 | about c|asting r|
|00000210| 65 73 75 6c 74 73 20 6f | 66 20 6d 65 6d 6f 72 79 |esults o|f memory|
|00000220| 20 61 6c 6c 6f 63 61 74 | 69 6f 6e 20 66 75 6e 63 | allocat|ion func|
|00000230| 74 69 6f 6e 73 20 6d 61 | 6c 6c 6f 63 28 33 29 2c |tions ma|lloc(3),|
|00000240| 0a 72 65 61 6c 6c 6f 63 | 28 33 29 2c 20 61 6e 64 |.realloc|(3), and|
|00000250| 20 63 61 6c 6c 6f 63 28 | 33 29 2e 20 20 49 74 20 | calloc(|3). It |
|00000260| 61 6c 73 6f 20 73 74 6f | 70 73 20 63 6f 6d 70 6c |also sto|ps compl|
|00000270| 61 69 6e 74 73 20 61 62 | 6f 75 74 20 74 68 65 20 |aints ab|out the |
|00000280| 61 72 67 75 6d 65 6e 74 | 20 6f 66 0a 66 72 65 65 |argument| of.free|
|00000290| 28 33 29 2e 0a 0a 23 21 | 20 2f 62 69 6e 2f 73 68 |(3)...#!| /bin/sh|
|000002a0| 0a 23 20 54 68 69 73 20 | 69 73 20 61 20 73 68 65 |.# This |is a she|
|000002b0| 6c 6c 20 61 72 63 68 69 | 76 65 2e 20 20 52 65 6d |ll archi|ve. Rem|
|000002c0| 6f 76 65 20 61 6e 79 74 | 68 69 6e 67 20 62 65 66 |ove anyt|hing bef|
|000002d0| 6f 72 65 20 74 68 69 73 | 20 6c 69 6e 65 2c 20 74 |ore this| line, t|
|000002e0| 68 65 6e 20 75 6e 70 61 | 63 6b 0a 23 20 69 74 20 |hen unpa|ck.# it |
|000002f0| 62 79 20 73 61 76 69 6e | 67 20 69 74 20 69 6e 74 |by savin|g it int|
|00000300| 6f 20 61 20 66 69 6c 65 | 20 61 6e 64 20 74 79 70 |o a file| and typ|
|00000310| 69 6e 67 20 22 73 68 20 | 66 69 6c 65 22 2e 20 20 |ing "sh |file". |
|00000320| 54 6f 20 6f 76 65 72 77 | 72 69 74 65 20 65 78 69 |To overw|rite exi|
|00000330| 73 74 69 6e 67 0a 23 20 | 66 69 6c 65 73 2c 20 74 |sting.# |files, t|
|00000340| 79 70 65 20 22 73 68 20 | 66 69 6c 65 20 2d 63 22 |ype "sh |file -c"|
|00000350| 2e 20 20 59 6f 75 20 63 | 61 6e 20 61 6c 73 6f 20 |. You c|an also |
|00000360| 66 65 65 64 20 74 68 69 | 73 20 61 73 20 73 74 61 |feed thi|s as sta|
|00000370| 6e 64 61 72 64 20 69 6e | 70 75 74 20 76 69 61 0a |ndard in|put via.|
|00000380| 23 20 75 6e 73 68 61 72 | 2c 20 6f 72 20 62 79 20 |# unshar|, or by |
|00000390| 74 79 70 69 6e 67 20 22 | 73 68 20 3c 66 69 6c 65 |typing "|sh <file|
|000003a0| 22 2c 20 65 2e 67 2e 2e | 20 20 49 66 20 74 68 69 |", e.g..| If thi|
|000003b0| 73 20 61 72 63 68 69 76 | 65 20 69 73 20 63 6f 6d |s archiv|e is com|
|000003c0| 70 6c 65 74 65 2c 20 79 | 6f 75 0a 23 20 77 69 6c |plete, y|ou.# wil|
|000003d0| 6c 20 73 65 65 20 74 68 | 65 20 66 6f 6c 6c 6f 77 |l see th|e follow|
|000003e0| 69 6e 67 20 6d 65 73 73 | 61 67 65 20 61 74 20 74 |ing mess|age at t|
|000003f0| 68 65 20 65 6e 64 3a 0a | 23 09 09 22 45 6e 64 20 |he end:.|#.."End |
|00000400| 6f 66 20 73 68 65 6c 6c | 20 61 72 63 68 69 76 65 |of shell| archive|
|00000410| 2e 22 0a 23 20 43 6f 6e | 74 65 6e 74 73 3a 20 20 |.".# Con|tents: |
|00000420| 52 45 41 44 4d 45 20 4d | 61 6b 65 66 69 6c 65 20 |README M|akefile |
|00000430| 67 6f 6f 64 20 6d 65 6d | 6c 69 6e 74 6f 6b 2e 33 |good mem|lintok.3|
|00000440| 20 6d 65 6d 6c 69 6e 74 | 6f 6b 2e 68 20 74 5f 6d | memlint|ok.h t_m|
|00000450| 65 6d 6c 69 6e 74 6f 6b | 2e 63 0a 50 41 54 48 3d |emlintok|.c.PATH=|
|00000460| 2f 62 69 6e 3a 2f 75 73 | 72 2f 62 69 6e 3a 2f 75 |/bin:/us|r/bin:/u|
|00000470| 73 72 2f 75 63 62 20 3b | 20 65 78 70 6f 72 74 20 |sr/ucb ;| export |
|00000480| 50 41 54 48 0a 69 66 20 | 74 65 73 74 20 2d 66 20 |PATH.if |test -f |
|00000490| 52 45 41 44 4d 45 20 2d | 61 20 22 24 7b 31 7d 22 |README -|a "${1}"|
|000004a0| 20 21 3d 20 22 2d 63 22 | 20 3b 20 74 68 65 6e 20 | != "-c"| ; then |
|000004b0| 0a 20 20 65 63 68 6f 20 | 73 68 61 72 3a 20 57 69 |. echo |shar: Wi|
|000004c0| 6c 6c 20 6e 6f 74 20 6f | 76 65 72 2d 77 72 69 74 |ll not o|ver-writ|
|000004d0| 65 20 65 78 69 73 74 69 | 6e 67 20 66 69 6c 65 20 |e existi|ng file |
|000004e0| 5c 22 52 45 41 44 4d 45 | 5c 22 0a 65 6c 73 65 0a |\"README|\".else.|
|000004f0| 65 63 68 6f 20 73 68 61 | 72 3a 20 45 78 74 72 61 |echo sha|r: Extra|
|00000500| 63 74 69 6e 67 20 5c 22 | 52 45 41 44 4d 45 5c 22 |cting \"|README\"|
|00000510| 20 5c 28 31 37 34 37 20 | 63 68 61 72 61 63 74 65 | \(1747 |characte|
|00000520| 72 73 5c 29 0a 73 65 64 | 20 22 73 2f 5e 58 2f 2f |rs\).sed| "s/^X//|
|00000530| 22 20 3e 52 45 41 44 4d | 45 20 3c 3c 27 45 4e 44 |" >READM|E <<'END|
|00000540| 5f 4f 46 5f 52 45 41 44 | 4d 45 27 0a 58 22 6d 65 |_OF_READ|ME'.X"me|
|00000550| 6d 6c 69 6e 74 6f 6b 2e | 68 22 20 69 73 20 61 20 |mlintok.|h" is a |
|00000560| 68 65 61 64 65 72 20 66 | 69 6c 65 20 74 68 61 74 |header f|ile that|
|00000570| 20 63 61 6e 20 62 65 20 | 75 73 65 64 20 74 6f 20 | can be |used to |
|00000580| 70 6f 6c 69 74 65 6c 79 | 20 73 68 75 74 20 6c 69 |politely| shut li|
|00000590| 6e 74 28 31 29 20 75 70 | 0a 58 61 62 6f 75 74 20 |nt(1) up|.Xabout |
|000005a0| 63 61 73 74 69 6e 67 20 | 72 65 73 75 6c 74 73 20 |casting |results |
|000005b0| 6f 66 20 6d 65 6d 6f 72 | 79 20 61 6c 6c 6f 63 61 |of memor|y alloca|
|000005c0| 74 69 6f 6e 20 66 75 6e | 63 74 69 6f 6e 73 20 6d |tion fun|ctions m|
|000005d0| 61 6c 6c 6f 63 28 33 29 | 2c 20 72 65 61 6c 6c 6f |alloc(3)|, reallo|
|000005e0| 63 28 33 29 2c 0a 58 61 | 6e 64 20 63 61 6c 6c 6f |c(3),.Xa|nd callo|
|000005f0| 63 28 33 29 2e 20 20 49 | 74 20 61 6c 73 6f 20 73 |c(3). I|t also s|
|00000600| 74 6f 70 73 20 63 6f 6d | 70 6c 61 69 6e 74 73 20 |tops com|plaints |
|00000610| 61 62 6f 75 74 20 74 68 | 65 20 61 72 67 75 6d 65 |about th|e argume|
|00000620| 6e 74 20 6f 66 20 66 72 | 65 65 28 33 29 2e 0a 58 |nt of fr|ee(3)..X|
|00000630| 0a 58 43 4f 4e 54 45 4e | 54 53 0a 58 2d 2d 2d 2d |.XCONTEN|TS.X----|
|00000640| 2d 2d 2d 2d 0a 58 46 69 | 6c 65 73 20 69 6e 20 74 |----.XFi|les in t|
|00000650| 68 69 73 20 64 69 73 74 | 72 69 62 75 74 69 6f 6e |his dist|ribution|
|00000660| 20 61 72 65 3a 0a 58 0a | 58 52 45 41 44 4d 45 09 | are:.X.|XREADME.|
|00000670| 09 09 79 6f 75 27 72 65 | 20 72 65 61 64 69 6e 67 |..you're| reading|
|00000680| 20 69 74 0a 58 4d 61 6b | 65 66 69 6c 65 09 09 68 | it.XMak|efile..h|
|00000690| 61 73 20 73 65 76 65 72 | 61 6c 20 75 73 65 66 75 |as sever|al usefu|
|000006a0| 6c 20 74 61 72 67 65 74 | 73 2c 20 69 6e 63 6c 75 |l target|s, inclu|
|000006b0| 64 69 6e 67 20 22 69 6e | 73 74 61 6c 6c 22 20 61 |ding "in|stall" a|
|000006c0| 6e 64 20 22 74 65 73 74 | 22 0a 58 67 6f 6f 64 09 |nd "test|".Xgood.|
|000006d0| 09 09 67 6f 6f 64 20 72 | 65 73 75 6c 74 73 20 66 |..good r|esults f|
|000006e0| 6f 72 20 22 6d 61 6b 65 | 20 74 65 73 74 22 0a 58 |or "make| test".X|
|000006f0| 6d 65 6d 6c 69 6e 74 6f | 6b 2e 33 09 09 6d 61 6e |memlinto|k.3..man|
|00000700| 20 70 61 67 65 0a 58 6d | 65 6d 6c 69 6e 74 6f 6b | page.Xm|emlintok|
|00000710| 2e 68 09 09 74 68 65 20 | 68 65 61 64 65 72 20 66 |.h..the |header f|
|00000720| 69 6c 65 20 69 74 73 65 | 6c 66 0a 58 74 5f 6d 65 |ile itse|lf.Xt_me|
|00000730| 6d 6c 69 6e 74 6f 6b 2e | 63 09 61 20 74 65 73 74 |mlintok.|c.a test|
|00000740| 2f 64 65 6d 6f 20 70 72 | 6f 67 72 61 6d 0a 58 0a |/demo pr|ogram.X.|
|00000750| 58 44 49 53 43 55 53 53 | 49 4f 4e 0a 58 2d 2d 2d |XDISCUSS|ION.X---|
|00000760| 2d 2d 2d 2d 2d 2d 2d 0a | 58 4f 6e 65 20 63 6f 6d |-------.|XOne com|
|00000770| 6d 6f 6e 20 77 61 79 20 | 6f 66 20 69 67 6e 6f 72 |mon way |of ignor|
|00000780| 69 6e 67 20 6c 69 6e 74 | 20 65 72 72 6f 72 73 20 |ing lint| errors |
|00000790| 69 73 20 74 6f 20 64 6f | 20 73 6f 6d 65 74 68 69 |is to do| somethi|
|000007a0| 6e 67 20 6c 69 6b 65 3a | 0a 58 0a 58 09 23 69 66 |ng like:|.X.X.#if|
|000007b0| 64 65 66 20 6c 69 6e 74 | 0a 58 09 23 64 65 66 69 |def lint|.X.#defi|
|000007c0| 6e 65 20 6d 61 6c 6c 6f | 63 28 61 72 67 29 20 4e |ne mallo|c(arg) N|
|000007d0| 55 4c 4c 0a 58 09 23 65 | 6e 64 69 66 0a 58 0a 58 |ULL.X.#e|ndif.X.X|
|000007e0| 54 68 65 20 74 72 6f 75 | 62 6c 65 20 77 69 74 68 |The trou|ble with|
|000007f0| 20 64 6f 69 6e 67 20 74 | 68 69 6e 67 73 20 74 68 | doing t|hings th|
|00000800| 69 73 20 77 61 79 20 69 | 73 20 74 68 61 74 20 6c |is way i|s that l|
|00000810| 69 6e 74 20 77 69 6c 6c | 20 6e 6f 74 20 74 68 65 |int will| not the|
|00000820| 6e 20 62 65 20 61 62 6c | 65 20 74 6f 0a 58 63 68 |n be abl|e to.Xch|
|00000830| 65 63 6b 20 6d 61 6c 6c | 6f 63 27 73 20 61 72 67 |eck mall|oc's arg|
|00000840| 75 6d 65 6e 74 2c 20 73 | 6f 20 79 6f 75 20 63 6f |ument, s|o you co|
|00000850| 75 6c 64 20 67 65 74 20 | 61 77 61 79 20 77 69 74 |uld get |away wit|
|00000860| 68 20 73 6f 6d 65 74 68 | 69 6e 67 20 6c 69 6b 65 |h someth|ing like|
|00000870| 3a 0a 58 0a 58 09 63 68 | 61 72 20 2a 70 3b 0a 58 |:.X.X.ch|ar *p;.X|
|00000880| 09 63 68 61 72 20 2a 71 | 3b 0a 58 09 2e 2e 2e 0a |.char *q|;.X.....|
|00000890| 58 09 70 20 3d 20 6d 61 | 6c 6c 6f 63 28 71 29 3b |X.p = ma|lloc(q);|
|000008a0| 0a 58 0a 58 54 68 65 20 | 6d 61 63 72 6f 73 20 68 |.X.XThe |macros h|
|000008b0| 65 72 65 20 61 72 65 20 | 61 20 62 69 74 20 6d 6f |ere are |a bit mo|
|000008c0| 72 65 20 73 6f 70 68 69 | 73 74 69 63 61 74 65 64 |re sophi|sticated|
|000008d0| 2c 20 73 6f 20 74 68 61 | 74 20 74 68 65 20 6d 65 |, so tha|t the me|
|000008e0| 6d 6f 72 79 20 66 75 6e | 63 74 69 6f 6e 73 0a 58 |mory fun|ctions.X|
|000008f0| 67 65 74 20 69 6e 76 6f | 6b 65 64 20 69 6e 20 61 |get invo|ked in a|
|00000900| 20 73 79 6e 74 61 63 74 | 69 63 61 6c 6c 79 20 63 | syntact|ically c|
|00000910| 6f 72 72 65 63 74 20 61 | 6e 64 20 70 72 6f 70 65 |orrect a|nd prope|
|00000920| 72 6c 79 2d 74 79 70 65 | 64 20 28 61 6c 74 68 6f |rly-type|d (altho|
|00000930| 75 67 68 0a 58 73 65 6d | 61 6e 74 69 63 61 6c 6c |ugh.Xsem|anticall|
|00000940| 79 20 69 6e 63 6f 72 72 | 65 63 74 29 20 66 61 73 |y incorr|ect) fas|
|00000950| 68 69 6f 6e 20 61 6e 64 | 20 74 68 65 20 61 72 67 |hion and| the arg|
|00000960| 75 6d 65 6e 74 73 20 67 | 65 74 20 63 68 65 63 6b |uments g|et check|
|00000970| 65 64 0a 58 69 6e 64 65 | 70 65 6e 64 65 6e 74 6c |ed.Xinde|pendentl|
|00000980| 79 2e 20 20 54 68 65 20 | 6d 61 6e 20 70 61 67 65 |y. The |man page|
|00000990| 20 64 65 73 63 72 69 62 | 65 73 20 74 68 65 69 72 | describ|es their|
|000009a0| 20 75 73 65 2e 0a 58 0a | 58 54 68 65 20 66 69 6c | use..X.|XThe fil|
|000009b0| 65 20 61 6c 73 6f 20 69 | 6e 63 6c 75 64 65 73 20 |e also i|ncludes |
|000009c0| 61 20 6d 61 63 72 6f 20 | 4d 52 5f 41 4c 4c 4f 43 |a macro |MR_ALLOC|
|000009d0| 5f 4c 49 4e 54 4f 4b 20 | 74 68 61 74 20 69 73 20 |_LINTOK |that is |
|000009e0| 73 69 6d 70 6c 79 20 61 | 20 63 6f 6d 70 61 63 74 |simply a| compact|
|000009f0| 20 66 6f 72 6d 0a 58 6f | 66 20 74 68 65 20 63 6f | form.Xo|f the co|
|00000a00| 6d 6d 6f 6e 6c 79 2d 6f | 63 63 75 72 72 69 6e 67 |mmonly-o|ccurring|
|00000a10| 20 63 6f 64 65 20 74 6f | 20 61 6c 6c 6f 63 61 74 | code to| allocat|
|00000a20| 65 20 6d 65 6d 6f 72 79 | 20 69 66 20 61 20 28 74 |e memory| if a (t|
|00000a30| 79 70 69 63 61 6c 6c 79 | 20 73 74 61 74 69 63 29 |ypically| static)|
|00000a40| 0a 58 70 6f 69 6e 74 65 | 72 20 69 73 20 4e 55 4c |.Xpointe|r is NUL|
|00000a50| 4c 20 61 6e 64 20 74 6f | 20 72 65 61 6c 6c 6f 63 |L and to| realloc|
|00000a60| 61 74 65 20 69 74 20 69 | 66 20 74 68 65 20 70 6f |ate it i|f the po|
|00000a70| 69 6e 74 65 72 20 69 73 | 6e 27 74 20 4e 55 4c 4c |inter is|n't NULL|
|00000a80| 2e 0a 58 0a 58 54 68 65 | 72 65 20 61 72 65 20 61 |..X.XThe|re are a|
|00000a90| 6c 73 6f 20 6d 61 63 72 | 6f 73 20 74 6f 20 64 6f |lso macr|os to do|
|00000aa0| 20 73 6f 6d 65 20 70 72 | 69 6d 69 74 69 76 65 20 | some pr|imitive |
|00000ab0| 65 78 63 65 70 74 69 6f | 6e 20 68 61 6e 64 6c 69 |exceptio|n handli|
|00000ac0| 6e 67 20 6f 66 20 74 68 | 65 20 6d 65 6d 6f 72 79 |ng of th|e memory|
|00000ad0| 0a 58 61 6c 6c 6f 63 61 | 74 69 6f 6e 20 66 75 6e |.Xalloca|tion fun|
|00000ae0| 63 74 69 6f 6e 2e 20 20 | 53 65 65 20 74 68 65 20 |ction. |See the |
|00000af0| 6d 61 6e 20 70 61 67 65 | 20 66 6f 72 20 6d 6f 72 |man page| for mor|
|00000b00| 65 20 6f 6e 20 74 68 65 | 73 65 2e 0a 58 0a 58 41 |e on the|se..X.XA|
|00000b10| 73 20 49 20 64 65 76 65 | 6c 6f 70 65 64 20 69 74 |s I deve|loped it|
|00000b20| 20 77 69 74 68 20 6d 79 | 20 6f 77 6e 20 72 65 73 | with my| own res|
|00000b30| 6f 75 72 63 65 73 2c 20 | 49 27 6d 20 72 65 6c 65 |ources, |I'm rele|
|00000b40| 61 73 69 6e 67 20 74 68 | 69 73 20 63 6f 64 65 20 |asing th|is code |
|00000b50| 74 6f 20 74 68 65 0a 58 | 70 75 62 6c 69 63 20 64 |to the.X|public d|
|00000b60| 6f 6d 61 69 6e 2e 20 20 | 49 20 68 65 72 65 62 79 |omain. |I hereby|
|00000b70| 20 64 65 6e 79 20 61 6e | 79 20 72 65 73 70 6f 6e | deny an|y respon|
|00000b80| 73 69 62 69 6c 69 74 79 | 20 66 6f 72 20 69 74 73 |sibility| for its|
|00000b90| 20 75 73 65 20 6f 72 20 | 61 6e 79 20 64 61 6d 61 | use or |any dama|
|00000ba0| 67 65 73 0a 58 72 65 73 | 75 6c 74 69 6e 67 20 66 |ges.Xres|ulting f|
|00000bb0| 72 6f 6d 20 73 61 6d 65 | 2e 0a 58 0a 58 4e 65 76 |rom same|..X.XNev|
|00000bc0| 65 72 74 68 65 6c 65 73 | 73 2c 20 69 66 20 61 6e |ertheles|s, if an|
|00000bd0| 79 6f 6e 65 20 68 61 73 | 20 61 6e 79 20 70 72 6f |yone has| any pro|
|00000be0| 62 6c 65 6d 73 20 77 69 | 74 68 20 69 74 2c 20 71 |blems wi|th it, q|
|00000bf0| 75 65 73 74 69 6f 6e 73 | 20 61 62 6f 75 74 20 69 |uestions| about i|
|00000c00| 74 2c 20 6f 72 0a 58 69 | 6d 70 72 6f 76 65 6d 65 |t, or.Xi|mproveme|
|00000c10| 6e 74 73 20 74 6f 20 69 | 74 2c 20 70 6c 65 61 73 |nts to i|t, pleas|
|00000c20| 65 20 6c 65 74 20 6d 65 | 20 6b 6e 6f 77 2e 0a 58 |e let me| know..X|
|00000c30| 0a 58 09 2d 20 42 6f 62 | 20 4c 65 77 69 73 0a 58 |.X.- Bob| Lewis.X|
|00000c40| 09 20 20 62 6f 62 6c 40 | 74 65 73 73 69 2e 75 75 |. bobl@|tessi.uu|
|00000c50| 63 70 0a 45 4e 44 5f 4f | 46 5f 52 45 41 44 4d 45 |cp.END_O|F_README|
|00000c60| 0a 69 66 20 74 65 73 74 | 20 31 37 34 37 20 2d 6e |.if test| 1747 -n|
|00000c70| 65 20 60 77 63 20 2d 63 | 20 3c 52 45 41 44 4d 45 |e `wc -c| <README|
|00000c80| 60 3b 20 74 68 65 6e 0a | 20 20 20 20 65 63 68 6f |`; then.| echo|
|00000c90| 20 73 68 61 72 3a 20 5c | 22 52 45 41 44 4d 45 5c | shar: \|"README\|
|00000ca0| 22 20 75 6e 70 61 63 6b | 65 64 20 77 69 74 68 20 |" unpack|ed with |
|00000cb0| 77 72 6f 6e 67 20 73 69 | 7a 65 21 0a 66 69 0a 23 |wrong si|ze!.fi.#|
|00000cc0| 20 65 6e 64 20 6f 66 20 | 6f 76 65 72 77 72 69 74 | end of |overwrit|
|00000cd0| 69 6e 67 20 63 68 65 63 | 6b 0a 66 69 0a 69 66 20 |ing chec|k.fi.if |
|00000ce0| 74 65 73 74 20 2d 66 20 | 4d 61 6b 65 66 69 6c 65 |test -f |Makefile|
|00000cf0| 20 2d 61 20 22 24 7b 31 | 7d 22 20 21 3d 20 22 2d | -a "${1|}" != "-|
|00000d00| 63 22 20 3b 20 74 68 65 | 6e 20 0a 20 20 65 63 68 |c" ; the|n . ech|
|00000d10| 6f 20 73 68 61 72 3a 20 | 57 69 6c 6c 20 6e 6f 74 |o shar: |Will not|
|00000d20| 20 6f 76 65 72 2d 77 72 | 69 74 65 20 65 78 69 73 | over-wr|ite exis|
|00000d30| 74 69 6e 67 20 66 69 6c | 65 20 5c 22 4d 61 6b 65 |ting fil|e \"Make|
|00000d40| 66 69 6c 65 5c 22 0a 65 | 6c 73 65 0a 65 63 68 6f |file\".e|lse.echo|
|00000d50| 20 73 68 61 72 3a 20 45 | 78 74 72 61 63 74 69 6e | shar: E|xtractin|
|00000d60| 67 20 5c 22 4d 61 6b 65 | 66 69 6c 65 5c 22 20 5c |g \"Make|file\" \|
|00000d70| 28 39 35 31 20 63 68 61 | 72 61 63 74 65 72 73 5c |(951 cha|racters\|
|00000d80| 29 0a 73 65 64 20 22 73 | 2f 5e 58 2f 2f 22 20 3e |).sed "s|/^X//" >|
|00000d90| 4d 61 6b 65 66 69 6c 65 | 20 3c 3c 27 45 4e 44 5f |Makefile| <<'END_|
|00000da0| 4f 46 5f 4d 61 6b 65 66 | 69 6c 65 27 0a 58 23 20 |OF_Makef|ile'.X# |
|00000db0| 24 48 65 61 64 65 72 3a | 20 4d 61 6b 65 66 69 6c |$Header:| Makefil|
|00000dc0| 65 2c 76 20 31 2e 34 20 | 38 39 2f 30 35 2f 30 32 |e,v 1.4 |89/05/02|
|00000dd0| 20 31 35 3a 30 36 3a 34 | 38 20 62 6f 62 6c 20 45 | 15:06:4|8 bobl E|
|00000de0| 78 70 20 24 0a 58 0a 58 | 64 65 66 61 75 6c 74 3a |xp $.X.X|default:|
|00000df0| 20 6e 65 77 0a 58 0a 58 | 23 0a 58 23 09 54 68 69 | new.X.X|#.X#.Thi|
|00000e00| 73 20 69 73 20 77 68 65 | 72 65 20 79 6f 75 20 77 |s is whe|re you w|
|00000e10| 61 6e 74 20 74 68 65 20 | 68 65 61 64 65 72 20 74 |ant the |header t|
|00000e20| 6f 20 67 6f 2e 20 20 49 | 74 20 6d 69 67 68 74 20 |o go. I|t might |
|00000e30| 62 65 20 61 64 76 69 73 | 61 62 6c 65 20 74 6f 0a |be advis|able to.|
|00000e40| 58 23 09 70 75 74 20 69 | 74 20 69 6e 20 73 6f 6d |X#.put i|t in som|
|00000e50| 65 20 6c 6f 63 61 6c 20 | 64 69 72 65 63 74 6f 72 |e local |director|
|00000e60| 79 20 72 61 74 68 65 72 | 20 74 68 61 6e 20 74 68 |y rather| than th|
|00000e70| 69 73 20 64 65 66 61 75 | 6c 74 20 6f 6e 65 2e 2e |is defau|lt one..|
|00000e80| 2e 0a 58 23 0a 58 48 44 | 52 5f 44 45 53 54 20 3d |..X#.XHD|R_DEST =|
|00000e90| 20 2f 75 73 72 2f 69 6e | 63 6c 75 64 65 0a 58 0a | /usr/in|clude.X.|
|00000ea0| 58 23 0a 58 23 09 54 68 | 65 20 6d 61 6e 20 70 61 |X#.X#.Th|e man pa|
|00000eb0| 67 65 20 67 6f 65 73 20 | 68 65 72 65 2e 20 20 41 |ge goes |here. A|
|00000ec0| 67 61 69 6e 2c 20 79 6f | 75 20 6d 61 79 20 68 61 |gain, yo|u may ha|
|00000ed0| 76 65 20 73 6f 6d 65 20 | 6c 6f 63 61 6c 20 70 6c |ve some |local pl|
|00000ee0| 61 63 65 20 74 6f 20 70 | 75 74 20 69 74 2e 0a 58 |ace to p|ut it..X|
|00000ef0| 23 0a 58 4d 41 4e 5f 44 | 45 53 54 20 3d 20 2f 75 |#.XMAN_D|EST = /u|
|00000f00| 73 72 2f 6d 61 6e 2f 6d | 61 6e 33 0a 58 0a 58 46 |sr/man/m|an3.X.XF|
|00000f10| 49 4c 45 53 20 3d 20 5c | 0a 58 09 52 45 41 44 4d |ILES = \|.X.READM|
|00000f20| 45 20 5c 0a 58 09 4d 61 | 6b 65 66 69 6c 65 20 5c |E \.X.Ma|kefile \|
|00000f30| 0a 58 09 67 6f 6f 64 20 | 5c 0a 58 09 6d 65 6d 6c |.X.good |\.X.meml|
|00000f40| 69 6e 74 6f 6b 2e 33 20 | 5c 0a 58 09 6d 65 6d 6c |intok.3 |\.X.meml|
|00000f50| 69 6e 74 6f 6b 2e 68 20 | 5c 0a 58 09 74 5f 6d 65 |intok.h |\.X.t_me|
|00000f60| 6d 6c 69 6e 74 6f 6b 2e | 63 0a 58 0a 58 63 6c 65 |mlintok.|c.X.Xcle|
|00000f70| 61 6e 3a 0a 58 09 72 6d | 20 2d 66 20 74 5f 6d 65 |an:.X.rm| -f t_me|
|00000f80| 6d 6c 69 6e 74 6f 6b 20 | 6e 65 77 20 63 6f 72 65 |mlintok |new core|
|00000f90| 20 61 2e 6f 75 74 20 2a | 2e 6f 20 6d 65 6d 6c 69 | a.out *|.o memli|
|00000fa0| 6e 74 6f 6b 2e 73 68 61 | 72 0a 58 0a 58 6e 65 77 |ntok.sha|r.X.Xnew|
|00000fb0| 3a 09 74 5f 6d 65 6d 6c | 69 6e 74 6f 6b 0a 58 09 |:.t_meml|intok.X.|
|00000fc0| 74 5f 6d 65 6d 6c 69 6e | 74 6f 6b 20 3e 6e 65 77 |t_memlin|tok >new|
|00000fd0| 0a 58 0a 58 74 5f 6d 65 | 6d 6c 69 6e 74 6f 6b 3a |.X.Xt_me|mlintok:|
|00000fe0| 09 74 5f 6d 65 6d 6c 69 | 6e 74 6f 6b 2e 63 20 6d |.t_memli|ntok.c m|
|00000ff0| 65 6d 6c 69 6e 74 6f 6b | 2e 68 0a 58 09 63 63 20 |emlintok|.h.X.cc |
|00001000| 74 5f 6d 65 6d 6c 69 6e | 74 6f 6b 2e 63 20 2d 6f |t_memlin|tok.c -o|
|00001010| 20 74 5f 6d 65 6d 6c 69 | 6e 74 6f 6b 0a 58 0a 58 | t_memli|ntok.X.X|
|00001020| 74 65 73 74 3a 09 6e 65 | 77 20 74 5f 6d 65 6d 6c |test:.ne|w t_meml|
|00001030| 69 6e 74 6f 6b 0a 58 09 | 40 65 63 68 6f 20 22 23 |intok.X.|@echo "#|
|00001040| 20 63 6f 6d 70 61 72 69 | 6e 67 20 6e 65 77 20 72 | compari|ng new r|
|00001050| 65 73 75 6c 74 73 20 77 | 69 74 68 20 6b 6e 6f 77 |esults w|ith know|
|00001060| 6e 20 67 6f 6f 64 20 6f | 6e 65 73 3a 22 0a 58 09 |n good o|nes:".X.|
|00001070| 64 69 66 66 20 6e 65 77 | 20 67 6f 6f 64 0a 58 09 |diff new| good.X.|
|00001080| 40 65 63 68 6f 20 22 23 | 20 73 68 6f 75 6c 64 20 |@echo "#| should |
|00001090| 62 65 20 6e 6f 20 6c 69 | 6e 74 20 65 72 72 6f 72 |be no li|nt error|
|000010a0| 73 3a 22 0a 58 09 6c 69 | 6e 74 20 2d 62 61 63 68 |s:".X.li|nt -bach|
|000010b0| 78 20 74 5f 6d 65 6d 6c | 69 6e 74 6f 6b 2e 63 0a |x t_meml|intok.c.|
|000010c0| 58 0a 58 75 70 64 61 74 | 65 3a 09 6e 65 77 0a 58 |X.Xupdat|e:.new.X|
|000010d0| 09 6d 76 20 2d 66 20 6e | 65 77 20 67 6f 6f 64 0a |.mv -f n|ew good.|
|000010e0| 58 0a 58 73 68 61 72 3a | 20 6d 65 6d 6c 69 6e 74 |X.Xshar:| memlint|
|000010f0| 6f 6b 2e 73 68 61 72 0a | 58 0a 58 6d 65 6d 6c 69 |ok.shar.|X.Xmemli|
|00001100| 6e 74 6f 6b 2e 73 68 61 | 72 3a 20 24 28 46 49 4c |ntok.sha|r: $(FIL|
|00001110| 45 53 29 0a 58 09 73 68 | 61 72 20 24 28 46 49 4c |ES).X.sh|ar $(FIL|
|00001120| 45 53 29 20 3e 6d 65 6d | 6c 69 6e 74 6f 6b 2e 73 |ES) >mem|lintok.s|
|00001130| 68 61 72 0a 58 0a 58 69 | 6e 73 74 61 6c 6c 3a 20 |har.X.Xi|nstall: |
|00001140| 6d 65 6d 6c 69 6e 74 6f | 6b 2e 68 20 6d 65 6d 6c |memlinto|k.h meml|
|00001150| 69 6e 74 6f 6b 2e 33 0a | 58 09 63 70 20 6d 65 6d |intok.3.|X.cp mem|
|00001160| 6c 69 6e 74 6f 6b 2e 68 | 20 24 28 48 44 52 5f 44 |lintok.h| $(HDR_D|
|00001170| 45 53 54 29 0a 58 09 63 | 70 20 6d 65 6d 6c 69 6e |EST).X.c|p memlin|
|00001180| 74 6f 6b 2e 33 20 24 28 | 4d 41 4e 5f 44 45 53 54 |tok.3 $(|MAN_DEST|
|00001190| 29 0a 58 0a 58 09 0a 45 | 4e 44 5f 4f 46 5f 4d 61 |).X.X..E|ND_OF_Ma|
|000011a0| 6b 65 66 69 6c 65 0a 69 | 66 20 74 65 73 74 20 39 |kefile.i|f test 9|
|000011b0| 35 31 20 2d 6e 65 20 60 | 77 63 20 2d 63 20 3c 4d |51 -ne `|wc -c <M|
|000011c0| 61 6b 65 66 69 6c 65 60 | 3b 20 74 68 65 6e 0a 20 |akefile`|; then. |
|000011d0| 20 20 20 65 63 68 6f 20 | 73 68 61 72 3a 20 5c 22 | echo |shar: \"|
|000011e0| 4d 61 6b 65 66 69 6c 65 | 5c 22 20 75 6e 70 61 63 |Makefile|\" unpac|
|000011f0| 6b 65 64 20 77 69 74 68 | 20 77 72 6f 6e 67 20 73 |ked with| wrong s|
|00001200| 69 7a 65 21 0a 66 69 0a | 23 20 65 6e 64 20 6f 66 |ize!.fi.|# end of|
|00001210| 20 6f 76 65 72 77 72 69 | 74 69 6e 67 20 63 68 65 | overwri|ting che|
|00001220| 63 6b 0a 66 69 0a 69 66 | 20 74 65 73 74 20 2d 66 |ck.fi.if| test -f|
|00001230| 20 67 6f 6f 64 20 2d 61 | 20 22 24 7b 31 7d 22 20 | good -a| "${1}" |
|00001240| 21 3d 20 22 2d 63 22 20 | 3b 20 74 68 65 6e 20 0a |!= "-c" |; then .|
|00001250| 20 20 65 63 68 6f 20 73 | 68 61 72 3a 20 57 69 6c | echo s|har: Wil|
|00001260| 6c 20 6e 6f 74 20 6f 76 | 65 72 2d 77 72 69 74 65 |l not ov|er-write|
|00001270| 20 65 78 69 73 74 69 6e | 67 20 66 69 6c 65 20 5c | existin|g file \|
|00001280| 22 67 6f 6f 64 5c 22 0a | 65 6c 73 65 0a 65 63 68 |"good\".|else.ech|
|00001290| 6f 20 73 68 61 72 3a 20 | 45 78 74 72 61 63 74 69 |o shar: |Extracti|
|000012a0| 6e 67 20 5c 22 67 6f 6f | 64 5c 22 20 5c 28 32 34 |ng \"goo|d\" \(24|
|000012b0| 34 20 63 68 61 72 61 63 | 74 65 72 73 5c 29 0a 73 |4 charac|ters\).s|
|000012c0| 65 64 20 22 73 2f 5e 58 | 2f 2f 22 20 3e 67 6f 6f |ed "s/^X|//" >goo|
|000012d0| 64 20 3c 3c 27 45 4e 44 | 5f 4f 46 5f 67 6f 6f 64 |d <<'END|_OF_good|
|000012e0| 27 0a 58 31 30 30 20 69 | 6e 74 73 20 6d 61 6c 6c |'.X100 i|nts mall|
|000012f0| 6f 63 27 64 0a 58 32 30 | 30 20 69 6e 74 73 20 72 |oc'd.X20|0 ints r|
|00001300| 65 61 6c 6c 6f 63 27 64 | 0a 58 32 35 20 69 6e 74 |ealloc'd|.X25 int|
|00001310| 73 20 6d 72 5f 61 6c 6c | 6f 63 27 64 20 28 72 65 |s mr_all|oc'd (re|
|00001320| 61 6c 6c 6f 63 27 64 29 | 0a 58 35 30 30 20 69 6e |alloc'd)|.X500 in|
|00001330| 74 73 20 63 61 6c 6c 6f | 63 27 64 0a 58 31 30 30 |ts callo|c'd.X100|
|00001340| 30 20 69 6e 74 73 20 6d | 72 5f 61 6c 6c 6f 63 27 |0 ints m|r_alloc'|
|00001350| 64 20 28 6d 61 6c 6c 6f | 63 27 64 29 0a 58 35 30 |d (mallo|c'd).X50|
|00001360| 20 69 6e 74 73 20 63 61 | 6c 6c 6f 63 27 64 20 28 | ints ca|lloc'd (|
|00001370| 6f 72 20 65 6c 73 65 29 | 0a 58 31 30 30 20 69 6e |or else)|.X100 in|
|00001380| 74 73 20 6d 61 6c 6c 6f | 63 27 64 20 28 6f 72 20 |ts mallo|c'd (or |
|00001390| 65 6c 73 65 29 0a 58 32 | 30 30 20 69 6e 74 73 20 |else).X2|00 ints |
|000013a0| 72 65 61 6c 6c 6f 63 27 | 64 20 28 6f 72 20 65 6c |realloc'|d (or el|
|000013b0| 73 65 29 0a 58 34 30 30 | 20 69 6e 74 73 20 6d 72 |se).X400| ints mr|
|000013c0| 5f 61 6c 6c 6f 63 27 64 | 20 28 72 65 61 6c 6c 6f |_alloc'd| (reallo|
|000013d0| 63 27 64 29 20 28 6f 72 | 20 65 6c 73 65 29 0a 45 |c'd) (or| else).E|
|000013e0| 4e 44 5f 4f 46 5f 67 6f | 6f 64 0a 69 66 20 74 65 |ND_OF_go|od.if te|
|000013f0| 73 74 20 32 34 34 20 2d | 6e 65 20 60 77 63 20 2d |st 244 -|ne `wc -|
|00001400| 63 20 3c 67 6f 6f 64 60 | 3b 20 74 68 65 6e 0a 20 |c <good`|; then. |
|00001410| 20 20 20 65 63 68 6f 20 | 73 68 61 72 3a 20 5c 22 | echo |shar: \"|
|00001420| 67 6f 6f 64 5c 22 20 75 | 6e 70 61 63 6b 65 64 20 |good\" u|npacked |
|00001430| 77 69 74 68 20 77 72 6f | 6e 67 20 73 69 7a 65 21 |with wro|ng size!|
|00001440| 0a 66 69 0a 23 20 65 6e | 64 20 6f 66 20 6f 76 65 |.fi.# en|d of ove|
|00001450| 72 77 72 69 74 69 6e 67 | 20 63 68 65 63 6b 0a 66 |rwriting| check.f|
|00001460| 69 0a 69 66 20 74 65 73 | 74 20 2d 66 20 6d 65 6d |i.if tes|t -f mem|
|00001470| 6c 69 6e 74 6f 6b 2e 33 | 20 2d 61 20 22 24 7b 31 |lintok.3| -a "${1|
|00001480| 7d 22 20 21 3d 20 22 2d | 63 22 20 3b 20 74 68 65 |}" != "-|c" ; the|
|00001490| 6e 20 0a 20 20 65 63 68 | 6f 20 73 68 61 72 3a 20 |n . ech|o shar: |
|000014a0| 57 69 6c 6c 20 6e 6f 74 | 20 6f 76 65 72 2d 77 72 |Will not| over-wr|
|000014b0| 69 74 65 20 65 78 69 73 | 74 69 6e 67 20 66 69 6c |ite exis|ting fil|
|000014c0| 65 20 5c 22 6d 65 6d 6c | 69 6e 74 6f 6b 2e 33 5c |e \"meml|intok.3\|
|000014d0| 22 0a 65 6c 73 65 0a 65 | 63 68 6f 20 73 68 61 72 |".else.e|cho shar|
|000014e0| 3a 20 45 78 74 72 61 63 | 74 69 6e 67 20 5c 22 6d |: Extrac|ting \"m|
|000014f0| 65 6d 6c 69 6e 74 6f 6b | 2e 33 5c 22 20 5c 28 34 |emlintok|.3\" \(4|
|00001500| 37 30 36 20 63 68 61 72 | 61 63 74 65 72 73 5c 29 |706 char|acters\)|
|00001510| 0a 73 65 64 20 22 73 2f | 5e 58 2f 2f 22 20 3e 6d |.sed "s/|^X//" >m|
|00001520| 65 6d 6c 69 6e 74 6f 6b | 2e 33 20 3c 3c 27 45 4e |emlintok|.3 <<'EN|
|00001530| 44 5f 4f 46 5f 6d 65 6d | 6c 69 6e 74 6f 6b 2e 33 |D_OF_mem|lintok.3|
|00001540| 27 0a 58 2e 54 48 20 4c | 49 4e 54 4f 4b 20 33 20 |'.X.TH L|INTOK 3 |
|00001550| 22 32 20 4d 61 79 20 31 | 39 38 39 22 0a 58 2e 53 |"2 May 1|989".X.S|
|00001560| 48 20 4e 41 4d 45 0a 58 | 6d 65 6d 6c 69 6e 74 6f |H NAME.X|memlinto|
|00001570| 6b 20 5c 2d 20 70 61 63 | 6b 61 67 65 20 74 6f 20 |k \- pac|kage to |
|00001580| 73 74 6f 70 20 6c 69 6e | 74 20 63 6f 6d 70 6c 61 |stop lin|t compla|
|00001590| 69 6e 74 73 20 61 62 6f | 75 74 20 6d 65 6d 6f 72 |ints abo|ut memor|
|000015a0| 79 20 61 6c 6c 6f 63 61 | 74 69 6f 6e 0a 58 2e 53 |y alloca|tion.X.S|
|000015b0| 48 20 53 59 4e 4f 50 53 | 49 53 0a 58 2e 4c 50 0a |H SYNOPS|IS.X.LP.|
|000015c0| 58 23 69 6e 63 6c 75 64 | 65 20 22 6d 65 6d 6c 69 |X#includ|e "memli|
|000015d0| 6e 74 6f 6b 2e 68 22 0a | 58 2e 53 48 20 44 45 53 |ntok.h".|X.SH DES|
|000015e0| 43 52 49 50 54 49 4f 4e | 0a 58 2e 4c 50 0a 58 54 |CRIPTION|.X.LP.XT|
|000015f0| 68 69 73 20 70 61 63 6b | 61 67 65 20 63 6f 6e 74 |his pack|age cont|
|00001600| 61 69 6e 73 20 63 70 70 | 20 6d 61 63 72 6f 20 64 |ains cpp| macro d|
|00001610| 65 66 69 6e 69 74 69 6f | 6e 73 20 74 68 61 74 0a |efinitio|ns that.|
|00001620| 58 73 74 6f 70 20 6c 69 | 6e 74 20 66 72 6f 6d 20 |Xstop li|nt from |
|00001630| 63 6f 6d 70 6c 61 69 6e | 69 6e 67 20 61 62 6f 75 |complain|ing abou|
|00001640| 74 20 74 68 65 20 6d 65 | 6d 6f 72 79 20 6d 61 6e |t the me|mory man|
|00001650| 61 67 65 6d 65 6e 74 20 | 66 75 6e 63 74 69 6f 6e |agement |function|
|00001660| 73 0a 58 2e 49 52 20 6d | 61 6c 6c 6f 63 20 28 33 |s.X.IR m|alloc (3|
|00001670| 29 2c 0a 58 2e 49 52 20 | 63 61 6c 6c 6f 63 20 28 |),.X.IR |calloc (|
|00001680| 33 29 2c 0a 58 2e 49 52 | 20 72 65 61 6c 6c 6f 63 |3),.X.IR| realloc|
|00001690| 20 28 33 29 2c 0a 58 61 | 6e 64 0a 58 2e 49 52 20 | (3),.Xa|nd.X.IR |
|000016a0| 66 72 65 65 20 28 33 29 | 0a 58 28 68 65 72 65 61 |free (3)|.X(herea|
|000016b0| 66 74 65 72 2c 20 77 65 | 27 6c 6c 20 63 61 6c 6c |fter, we|'ll call|
|000016c0| 20 74 68 65 73 65 20 74 | 68 65 20 22 5c 66 49 2a | these t|he "\fI*|
|000016d0| 61 6c 6c 6f 63 5c 66 50 | 28 33 29 22 20 66 75 6e |alloc\fP|(3)" fun|
|000016e0| 63 74 69 6f 6e 73 29 2c | 0a 58 77 68 69 6c 65 20 |ctions),|.Xwhile |
|000016f0| 61 74 20 74 68 65 20 73 | 61 6d 65 20 74 69 6d 65 |at the s|ame time|
|00001700| 20 70 65 72 66 6f 72 6d | 69 6e 67 20 63 68 65 63 | perform|ing chec|
|00001710| 6b 73 20 6f 66 20 74 68 | 65 69 72 20 61 72 67 75 |ks of th|eir argu|
|00001720| 6d 65 6e 74 73 2e 0a 58 | 54 68 65 72 65 20 61 72 |ments..X|There ar|
|00001730| 65 20 74 77 6f 20 73 65 | 74 73 20 6f 66 20 6d 61 |e two se|ts of ma|
|00001740| 63 72 6f 73 20 64 65 66 | 69 6e 65 64 20 68 65 72 |cros def|ined her|
|00001750| 65 3a 20 6f 6e 65 20 77 | 69 74 68 6f 75 74 20 65 |e: one w|ithout e|
|00001760| 78 63 65 70 74 69 6f 6e | 20 68 61 6e 64 6c 69 6e |xception| handlin|
|00001770| 67 0a 58 28 6c 69 6b 65 | 20 74 68 65 0a 58 2e 49 |g.X(like| the.X.I|
|00001780| 52 20 2a 61 6c 6c 6f 63 | 20 28 33 29 0a 58 66 75 |R *alloc| (3).Xfu|
|00001790| 6e 63 74 69 6f 6e 73 20 | 74 68 65 6d 73 65 6c 76 |nctions |themselv|
|000017a0| 65 73 29 20 61 6e 64 20 | 6f 6e 65 20 77 69 74 68 |es) and |one with|
|000017b0| 2e 0a 58 2e 4c 50 0a 58 | 54 68 65 20 6d 61 63 72 |..X.LP.X|The macr|
|000017c0| 6f 73 20 77 69 74 68 6f | 75 74 20 65 78 63 65 70 |os witho|ut excep|
|000017d0| 74 69 6f 6e 20 68 61 6e | 64 6c 69 6e 67 20 61 72 |tion han|dling ar|
|000017e0| 65 3a 0a 58 2e 49 50 20 | 22 22 0a 58 43 41 4c 4c |e:.X.IP |"".XCALL|
|000017f0| 4f 43 5f 4c 49 4e 54 4f | 4b 28 70 74 72 2c 20 6e |OC_LINTO|K(ptr, n|
|00001800| 65 6c 65 6d 2c 20 74 79 | 70 65 29 0a 58 2e 62 72 |elem, ty|pe).X.br|
|00001810| 0a 58 4d 41 4c 4c 4f 43 | 5f 4c 49 4e 54 4f 4b 28 |.XMALLOC|_LINTOK(|
|00001820| 70 74 72 2c 20 6e 65 6c | 65 6d 2c 20 74 79 70 65 |ptr, nel|em, type|
|00001830| 29 0a 58 2e 62 72 0a 58 | 52 45 41 4c 4c 4f 43 5f |).X.br.X|REALLOC_|
|00001840| 4c 49 4e 54 4f 4b 28 70 | 74 72 2c 20 6e 65 6c 65 |LINTOK(p|tr, nele|
|00001850| 6d 2c 20 74 79 70 65 29 | 0a 58 2e 62 72 0a 58 46 |m, type)|.X.br.XF|
|00001860| 52 45 45 5f 4c 49 4e 54 | 4f 4b 28 70 74 72 29 0a |REE_LINT|OK(ptr).|
|00001870| 58 2e 62 72 0a 58 2e 4c | 50 0a 58 77 68 65 72 65 |X.br.X.L|P.Xwhere|
|00001880| 20 22 70 74 72 22 20 69 | 73 20 61 20 76 61 72 69 | "ptr" i|s a vari|
|00001890| 61 62 6c 65 20 6f 66 20 | 74 79 70 65 20 22 74 79 |able of |type "ty|
|000018a0| 70 65 20 2a 22 2e 20 20 | 41 66 74 65 72 20 69 6e |pe *". |After in|
|000018b0| 76 6f 6b 69 6e 67 20 61 | 6e 79 0a 58 6f 66 20 74 |voking a|ny.Xof t|
|000018c0| 68 65 20 22 2a 41 4c 4c | 4f 43 5f 4c 49 4e 54 4f |he "*ALL|OC_LINTO|
|000018d0| 4b 22 20 6d 61 63 72 6f | 73 2c 20 22 70 74 72 22 |K" macro|s, "ptr"|
|000018e0| 20 77 69 6c 6c 20 65 69 | 74 68 65 72 20 62 65 20 | will ei|ther be |
|000018f0| 4e 55 4c 4c 20 28 69 66 | 20 61 6e 64 0a 58 6f 6e |NULL (if| and.Xon|
|00001900| 6c 79 20 69 66 20 74 68 | 65 0a 58 75 6e 64 65 72 |ly if th|e.Xunder|
|00001910| 6c 79 69 6e 67 20 66 75 | 6e 63 74 69 6f 6e 20 72 |lying fu|nction r|
|00001920| 65 74 75 72 6e 65 64 20 | 69 74 29 20 6f 72 20 69 |eturned |it) or i|
|00001930| 74 20 77 69 6c 6c 20 70 | 6f 69 6e 74 20 74 6f 20 |t will p|oint to |
|00001940| 61 6e 20 61 72 72 61 79 | 20 6f 66 0a 58 22 6e 65 |an array| of.X"ne|
|00001950| 6c 65 6d 22 20 6f 62 6a | 65 63 74 73 20 6f 66 20 |lem" obj|ects of |
|00001960| 74 79 70 65 20 22 74 79 | 70 65 22 2e 0a 58 2e 4c |type "ty|pe"..X.L|
|00001970| 50 0a 58 4e 6f 74 65 20 | 74 68 61 74 20 74 68 65 |P.XNote |that the|
|00001980| 20 75 73 61 67 65 20 6f | 66 20 4d 41 4c 4c 4f 43 | usage o|f MALLOC|
|00001990| 5f 4c 49 4e 54 4f 4b 2c | 20 43 41 4c 4c 4f 43 5f |_LINTOK,| CALLOC_|
|000019a0| 4c 49 4e 54 4f 4b 2c 20 | 61 6e 64 0a 58 52 45 41 |LINTOK, |and.XREA|
|000019b0| 4c 4c 4f 43 5f 4c 49 4e | 54 4f 4b 20 72 65 71 75 |LLOC_LIN|TOK requ|
|000019c0| 69 72 65 73 20 6d 6f 72 | 65 20 74 68 61 6e 20 61 |ires mor|e than a|
|000019d0| 20 6e 61 6d 65 20 63 68 | 61 6e 67 65 2e 20 20 41 | name ch|ange. A|
|000019e0| 6e 20 6f 72 69 67 69 6e | 61 6c 0a 58 63 61 6c 6c |n origin|al.Xcall|
|000019f0| 20 6f 66 20 74 68 65 20 | 66 6f 72 6d 3a 0a 58 2e | of the |form:.X.|
|00001a00| 49 50 0a 58 70 74 72 20 | 3d 20 28 74 79 70 65 20 |IP.Xptr |= (type |
|00001a10| 2a 29 20 6d 61 6c 6c 6f | 63 28 6e 65 6c 65 6d 20 |*) mallo|c(nelem |
|00001a20| 2a 20 73 69 7a 65 6f 66 | 28 74 79 70 65 29 29 0a |* sizeof|(type)).|
|00001a30| 58 2e 4c 50 0a 58 6d 75 | 73 74 20 62 65 20 72 65 |X.LP.Xmu|st be re|
|00001a40| 70 6c 61 63 65 64 20 62 | 79 0a 58 2e 49 50 0a 58 |placed b|y.X.IP.X|
|00001a50| 4d 41 4c 4c 4f 43 5f 4c | 49 4e 54 4f 4b 28 70 74 |MALLOC_L|INTOK(pt|
|00001a60| 72 2c 20 6e 65 6c 65 6d | 2c 20 74 79 70 65 29 0a |r, nelem|, type).|
|00001a70| 58 2e 4c 50 0a 58 61 6e | 64 20 73 69 6d 69 6c 61 |X.LP.Xan|d simila|
|00001a80| 72 6c 79 20 66 6f 72 20 | 43 41 4c 4c 4f 43 5f 4c |rly for |CALLOC_L|
|00001a90| 49 4e 54 4f 4b 20 61 6e | 64 20 52 45 41 4c 4c 4f |INTOK an|d REALLO|
|00001aa0| 43 5f 4c 49 4e 54 4f 4b | 2e 20 20 41 6c 6c 20 74 |C_LINTOK|. All t|
|00001ab0| 68 72 65 65 0a 58 6d 61 | 63 72 6f 73 20 22 72 65 |hree.Xma|cros "re|
|00001ac0| 74 75 72 6e 22 20 76 61 | 6c 75 65 73 20 61 6e 64 |turn" va|lues and|
|00001ad0| 20 6d 61 79 20 74 68 65 | 72 65 66 6f 72 65 20 62 | may the|refore b|
|00001ae0| 65 20 75 73 65 64 20 61 | 73 20 70 61 72 74 20 6f |e used a|s part o|
|00001af0| 66 0a 58 65 78 70 72 65 | 73 73 69 6f 6e 73 2e 0a |f.Xexpre|ssions..|
|00001b00| 58 2e 4c 50 0a 58 49 66 | 20 61 20 6d 61 63 72 6f |X.LP.XIf| a macro|
|00001b10| 27 73 20 72 65 73 75 6c | 74 20 69 73 20 63 6f 6d |'s resul|t is com|
|00001b20| 70 61 72 65 64 20 77 69 | 74 68 20 4e 55 4c 4c 2c |pared wi|th NULL,|
|00001b30| 20 6c 69 6e 74 20 77 69 | 6c 6c 20 75 73 75 61 6c | lint wi|ll usual|
|00001b40| 6c 79 20 63 6f 6d 70 6c | 61 69 6e 0a 58 69 66 20 |ly compl|ain.Xif |
|00001b50| 4e 55 4c 4c 20 69 73 20 | 63 61 73 74 20 74 6f 20 |NULL is |cast to |
|00001b60| 61 6e 79 74 68 69 6e 67 | 2e 20 20 46 6f 72 20 65 |anything|. For e|
|00001b70| 78 61 6d 70 6c 65 2c 20 | 74 68 69 73 20 77 69 6c |xample, |this wil|
|00001b80| 6c 20 70 72 6f 64 75 63 | 65 20 61 20 6c 69 6e 74 |l produc|e a lint|
|00001b90| 20 65 72 72 6f 72 3a 0a | 58 2e 49 50 0a 58 69 6e | error:.|X.IP.Xin|
|00001ba0| 74 20 2a 69 61 3b 0a 58 | 2e 62 72 0a 58 20 2e 2e |t *ia;.X|.br.X ..|
|00001bb0| 2e 0a 58 2e 62 72 0a 58 | 69 66 20 28 4d 41 4c 4c |..X.br.X|if (MALL|
|00001bc0| 4f 43 5f 4c 49 4e 54 4f | 4b 28 69 61 2c 20 34 32 |OC_LINTO|K(ia, 42|
|00001bd0| 2c 20 69 6e 74 29 20 3d | 3d 20 28 69 6e 74 20 2a |, int) =|= (int *|
|00001be0| 29 20 4e 55 4c 4c 29 0a | 58 2e 62 72 0a 58 20 2e |) NULL).|X.br.X .|
|00001bf0| 2e 2e 0a 58 2e 4c 50 0a | 58 42 75 74 20 73 69 6e |...X.LP.|XBut sin|
|00001c00| 63 65 20 75 6e 63 61 73 | 74 20 30 20 28 69 2e 65 |ce uncas|t 0 (i.e|
|00001c10| 2e 2c 20 4e 55 4c 4c 29 | 20 69 73 20 61 6c 77 61 |., NULL)| is alwa|
|00001c20| 79 73 20 61 20 76 61 6c | 69 64 20 70 6f 69 6e 74 |ys a val|id point|
|00001c30| 65 72 2c 20 69 74 0a 58 | 69 73 20 75 6e 6e 65 63 |er, it.X|is unnec|
|00001c40| 65 73 73 61 72 79 20 74 | 6f 20 63 61 73 74 20 69 |essary t|o cast i|
|00001c50| 74 20 74 6f 20 61 6e 79 | 74 68 69 6e 67 2e 0a 58 |t to any|thing..X|
|00001c60| 52 65 6d 6f 76 69 6e 67 | 20 74 68 65 20 63 61 73 |Removing| the cas|
|00001c70| 74 20 73 74 6f 70 73 20 | 74 68 65 20 6c 69 6e 74 |t stops |the lint|
|00001c80| 20 63 6f 6d 70 6c 61 69 | 6e 74 3a 0a 58 2e 49 50 | complai|nt:.X.IP|
|00001c90| 0a 58 20 2e 2e 2e 0a 58 | 2e 62 72 0a 58 69 66 20 |.X ....X|.br.Xif |
|00001ca0| 28 4d 41 4c 4c 4f 43 5f | 4c 49 4e 54 4f 4b 28 69 |(MALLOC_|LINTOK(i|
|00001cb0| 61 2c 20 34 32 2c 20 69 | 6e 74 29 20 3d 3d 20 4e |a, 42, i|nt) == N|
|00001cc0| 55 4c 4c 29 0a 58 2e 62 | 72 0a 58 20 2e 2e 2e 0a |ULL).X.b|r.X ....|
|00001cd0| 58 2e 4c 50 0a 58 49 66 | 20 74 68 65 20 6d 61 63 |X.LP.XIf| the mac|
|00001ce0| 72 6f 20 69 6e 76 6f 63 | 61 74 69 6f 6e 20 64 6f |ro invoc|ation do|
|00001cf0| 65 73 6e 27 74 20 61 70 | 70 65 61 72 20 77 69 74 |esn't ap|pear wit|
|00001d00| 68 69 6e 20 61 6e 20 65 | 78 70 72 65 73 73 69 6f |hin an e|xpressio|
|00001d10| 6e 2c 0a 58 79 6f 75 20 | 77 69 6c 6c 20 6e 65 65 |n,.Xyou |will nee|
|00001d20| 64 20 74 6f 20 63 61 73 | 74 20 74 68 65 20 2a 41 |d to cas|t the *A|
|00001d30| 4c 4c 4f 43 5f 4c 49 4e | 54 4f 4b 28 29 0a 58 69 |LLOC_LIN|TOK().Xi|
|00001d40| 6e 76 6f 63 61 74 69 6f | 6e 73 20 74 6f 0a 58 2e |nvocatio|ns to.X.|
|00001d50| 42 20 76 6f 69 64 0a 58 | 69 66 20 79 6f 75 20 77 |B void.X|if you w|
|00001d60| 61 6e 74 20 74 6f 20 67 | 65 74 20 72 69 64 20 6f |ant to g|et rid o|
|00001d70| 66 20 74 68 65 0a 58 22 | 2a 61 6c 6c 6f 63 20 72 |f the.X"|*alloc r|
|00001d80| 65 74 75 72 6e 73 20 76 | 61 6c 75 65 20 77 68 69 |eturns v|alue whi|
|00001d90| 63 68 20 69 73 20 73 6f | 6d 65 74 69 6d 65 73 20 |ch is so|metimes |
|00001da0| 69 67 6e 6f 72 65 64 22 | 0a 58 61 6e 64 0a 58 22 |ignored"|.Xand.X"|
|00001db0| 2a 61 6c 6c 6f 63 20 72 | 65 74 75 72 6e 73 20 76 |*alloc r|eturns v|
|00001dc0| 61 6c 75 65 20 77 68 69 | 63 68 20 69 73 20 61 6c |alue whi|ch is al|
|00001dd0| 77 61 79 73 20 69 67 6e | 6f 72 65 64 22 0a 58 6d |ways ign|ored".Xm|
|00001de0| 65 73 73 61 67 65 73 2e | 0a 58 2e 4c 50 0a 58 59 |essages.|.X.LP.XY|
|00001df0| 6f 75 20 63 61 6e 20 6d | 69 78 20 69 6e 76 6f 63 |ou can m|ix invoc|
|00001e00| 61 74 69 6f 6e 73 20 6f | 66 20 74 68 65 73 65 20 |ations o|f these |
|00001e10| 6d 61 63 72 6f 73 20 77 | 69 74 68 20 63 61 6c 6c |macros w|ith call|
|00001e20| 73 20 74 6f 20 74 68 65 | 20 6f 72 69 67 69 6e 61 |s to the| origina|
|00001e30| 6c 0a 58 66 75 6e 63 74 | 69 6f 6e 73 2e 20 20 54 |l.Xfunct|ions. T|
|00001e40| 68 65 20 6f 6e 6c 79 20 | 64 69 66 66 65 72 65 6e |he only |differen|
|00001e50| 63 65 20 69 73 20 69 6e | 20 74 68 65 20 6c 69 6e |ce is in| the lin|
|00001e60| 74 20 62 65 68 61 76 69 | 6f 72 2e 0a 58 2e 4c 50 |t behavi|or..X.LP|
|00001e70| 0a 58 41 20 63 6f 6d 6d | 6f 6e 20 77 61 79 20 6f |.XA comm|on way o|
|00001e80| 66 20 69 6e 76 6f 6b 69 | 6e 67 20 74 68 65 20 6d |f invoki|ng the m|
|00001e90| 65 6d 6f 72 79 20 6d 61 | 6e 61 67 65 6d 65 6e 74 |emory ma|nagement|
|00001ea0| 20 66 75 6e 63 74 69 6f | 6e 73 20 69 73 20 74 6f | functio|ns is to|
|00001eb0| 20 63 61 6c 6c 0a 58 2e | 49 52 20 6d 61 6c 6c 6f | call.X.|IR mallo|
|00001ec0| 63 20 28 29 0a 58 69 66 | 20 61 0a 58 70 6f 69 6e |c ().Xif| a.Xpoin|
|00001ed0| 74 65 72 20 69 73 20 4e | 55 4c 4c 20 28 75 73 75 |ter is N|ULL (usu|
|00001ee0| 61 6c 6c 79 20 74 68 65 | 20 66 69 72 73 74 20 74 |ally the| first t|
|00001ef0| 69 6d 65 20 69 74 27 73 | 20 73 65 74 29 20 61 6e |ime it's| set) an|
|00001f00| 64 0a 58 2e 49 52 20 72 | 65 61 6c 6c 6f 63 20 28 |d.X.IR r|ealloc (|
|00001f10| 29 0a 58 69 66 20 69 74 | 20 69 73 6e 27 74 20 4e |).Xif it| isn't N|
|00001f20| 55 4c 4c 20 28 75 73 75 | 61 6c 6c 79 20 6f 6e 20 |ULL (usu|ally on |
|00001f30| 73 75 62 73 65 71 75 65 | 6e 74 20 74 69 6d 65 73 |subseque|nt times|
|00001f40| 29 2e 20 20 54 68 65 20 | 73 69 6d 70 6c 65 20 6d |). The |simple m|
|00001f50| 61 63 72 6f 0a 58 2e 49 | 50 0a 58 4d 52 5f 41 4c |acro.X.I|P.XMR_AL|
|00001f60| 4c 4f 43 5f 4c 49 4e 54 | 4f 4b 28 70 74 72 2c 20 |LOC_LINT|OK(ptr, |
|00001f70| 6e 65 6c 65 6d 2c 20 74 | 79 70 65 29 0a 58 2e 4c |nelem, t|ype).X.L|
|00001f80| 50 0a 58 64 6f 65 73 20 | 74 68 69 73 20 77 69 74 |P.Xdoes |this wit|
|00001f90| 68 20 4d 41 4c 4c 4f 43 | 5f 4c 49 4e 54 4f 4b 28 |h MALLOC|_LINTOK(|
|00001fa0| 29 20 61 6e 64 20 52 45 | 41 4c 4c 4f 43 5f 4c 49 |) and RE|ALLOC_LI|
|00001fb0| 4e 54 4f 4b 28 29 2e 0a | 58 2e 4c 50 0a 58 53 69 |NTOK()..|X.LP.XSi|
|00001fc0| 6e 63 65 20 6d 65 6d 6f | 72 79 20 61 6c 6c 6f 63 |nce memo|ry alloc|
|00001fd0| 61 74 69 6f 6e 20 66 61 | 69 6c 75 72 65 20 69 73 |ation fa|ilure is|
|00001fe0| 20 6f 66 74 65 6e 20 61 | 6e 20 65 78 63 65 70 74 | often a|n except|
|00001ff0| 69 6f 6e 61 6c 20 63 6f | 6e 64 69 74 69 6f 6e 2c |ional co|ndition,|
|00002000| 0a 58 22 6d 65 6d 6c 69 | 6e 74 6f 6b 2e 68 22 20 |.X"memli|ntok.h" |
|00002010| 61 6c 73 6f 20 68 61 73 | 20 64 65 66 69 6e 69 74 |also has| definit|
|00002020| 69 6f 6e 73 20 6f 66 20 | 66 6f 75 72 20 6f 74 68 |ions of |four oth|
|00002030| 65 72 20 75 73 65 66 75 | 6c 20 6d 61 63 72 6f 73 |er usefu|l macros|
|00002040| 20 74 68 61 74 20 69 6e | 63 6c 75 64 65 0a 58 65 | that in|clude.Xe|
|00002050| 78 63 65 70 74 69 6f 6e | 20 68 61 6e 64 6c 69 6e |xception| handlin|
|00002060| 67 3a 0a 58 2e 49 50 0a | 58 43 41 4c 4c 4f 43 5f |g:.X.IP.|XCALLOC_|
|00002070| 4f 52 5f 45 4c 53 45 5f | 4c 49 4e 54 4f 4b 28 70 |OR_ELSE_|LINTOK(p|
|00002080| 74 72 2c 20 6e 65 6c 65 | 6d 2c 20 74 79 70 65 29 |tr, nele|m, type)|
|00002090| 0a 58 2e 62 72 0a 58 4d | 41 4c 4c 4f 43 5f 4f 52 |.X.br.XM|ALLOC_OR|
|000020a0| 5f 45 4c 53 45 5f 4c 49 | 4e 54 4f 4b 28 70 74 72 |_ELSE_LI|NTOK(ptr|
|000020b0| 2c 20 6e 65 6c 65 6d 2c | 20 74 79 70 65 29 0a 58 |, nelem,| type).X|
|000020c0| 2e 62 72 0a 58 52 45 41 | 4c 4c 4f 43 5f 4f 52 5f |.br.XREA|LLOC_OR_|
|000020d0| 45 4c 53 45 5f 4c 49 4e | 54 4f 4b 28 70 74 72 2c |ELSE_LIN|TOK(ptr,|
|000020e0| 20 6e 65 6c 65 6d 2c 20 | 74 79 70 65 29 0a 58 2e | nelem, |type).X.|
|000020f0| 62 72 0a 58 4d 52 5f 41 | 4c 4c 4f 43 5f 4f 52 5f |br.XMR_A|LLOC_OR_|
|00002100| 45 4c 53 45 5f 4c 49 4e | 54 4f 4b 28 70 74 72 2c |ELSE_LIN|TOK(ptr,|
|00002110| 20 6e 65 6c 65 6d 2c 20 | 74 79 70 65 29 0a 58 2e | nelem, |type).X.|
|00002120| 62 72 0a 58 2e 4c 50 0a | 58 45 61 63 68 20 6f 66 |br.X.LP.|XEach of|
|00002130| 20 74 68 65 73 65 20 6d | 61 63 72 6f 73 20 69 6e | these m|acros in|
|00002140| 76 6f 6b 65 73 20 74 68 | 65 20 63 6f 72 72 65 73 |vokes th|e corres|
|00002150| 70 6f 6e 64 69 6e 67 20 | 2a 41 4c 4c 4f 43 5f 4c |ponding |*ALLOC_L|
|00002160| 49 4e 54 4f 4b 28 29 20 | 6d 61 63 72 6f 20 61 6e |INTOK() |macro an|
|00002170| 64 2c 0a 58 69 66 20 74 | 68 61 74 20 6d 61 63 72 |d,.Xif t|hat macr|
|00002180| 6f 20 66 61 69 6c 73 2c | 20 69 6e 76 6f 6b 65 73 |o fails,| invokes|
|00002190| 20 61 6e 6f 74 68 65 72 | 20 6d 61 63 72 6f 3a 0a | another| macro:.|
|000021a0| 58 2e 49 50 0a 58 45 52 | 52 4f 52 5f 45 58 49 54 |X.IP.XER|ROR_EXIT|
|000021b0| 5f 4c 49 4e 54 4f 4b 28 | 6e 65 6c 65 6d 2c 20 73 |_LINTOK(|nelem, s|
|000021c0| 69 7a 65 29 0a 58 2e 4c | 50 0a 58 57 68 65 72 65 |ize).X.L|P.XWhere|
|000021d0| 20 22 6e 65 6c 65 6d 22 | 20 69 73 20 74 68 65 20 | "nelem"| is the |
|000021e0| 6e 75 6d 62 65 72 20 6f | 66 20 65 6c 65 6d 65 6e |number o|f elemen|
|000021f0| 74 73 20 6f 66 20 22 73 | 69 7a 65 22 20 62 79 74 |ts of "s|ize" byt|
|00002200| 65 73 20 61 74 74 65 6d | 70 74 69 6e 67 20 74 6f |es attem|pting to|
|00002210| 20 62 65 0a 58 61 6c 6c | 6f 63 61 74 65 64 2e 0a | be.Xall|ocated..|
|00002220| 58 2e 4c 50 0a 58 41 20 | 64 65 66 61 75 6c 74 20 |X.LP.XA |default |
|00002230| 45 52 52 4f 52 5f 45 58 | 49 54 5f 4c 49 4e 54 4f |ERROR_EX|IT_LINTO|
|00002240| 4b 28 6e 65 6c 65 6d 2c | 20 73 69 7a 65 29 2c 20 |K(nelem,| size), |
|00002250| 77 68 69 63 68 20 70 72 | 69 6e 74 73 20 61 6e 20 |which pr|ints an |
|00002260| 69 6e 66 6f 72 6d 61 74 | 69 76 65 0a 58 6d 65 73 |informat|ive.Xmes|
|00002270| 73 61 67 65 20 61 6e 64 | 20 64 69 65 73 2c 20 69 |sage and| dies, i|
|00002280| 73 20 61 6c 73 6f 20 64 | 65 66 69 6e 65 64 2c 20 |s also d|efined, |
|00002290| 62 75 74 20 79 6f 75 20 | 61 72 65 20 66 72 65 65 |but you |are free|
|000022a0| 20 74 6f 20 72 65 64 65 | 66 69 6e 65 20 69 74 0a | to rede|fine it.|
|000022b0| 58 28 61 66 74 65 72 20 | 69 6e 63 6c 75 64 69 6e |X(after |includin|
|000022c0| 67 20 22 6d 65 6d 6c 69 | 6e 74 6f 6b 2e 68 22 20 |g "memli|ntok.h" |
|000022d0| 61 6e 64 20 62 65 66 6f | 72 65 20 69 6e 76 6f 6b |and befo|re invok|
|000022e0| 69 6e 67 20 61 6e 79 20 | 6f 66 20 74 68 65 20 6d |ing any |of the m|
|000022f0| 61 63 72 6f 73 20 68 65 | 72 65 69 6e 0a 58 2d 2d |acros he|rein.X--|
|00002300| 20 72 65 6d 65 6d 62 65 | 72 20 74 6f 20 22 23 75 | remembe|r to "#u|
|00002310| 6e 64 65 66 20 45 52 52 | 4f 52 5f 45 58 49 54 5f |ndef ERR|OR_EXIT_|
|00002320| 4c 49 4e 54 4f 4b 22 20 | 66 69 72 73 74 29 0a 58 |LINTOK" |first).X|
|00002330| 69 66 20 79 6f 75 20 77 | 61 6e 74 20 74 6f 20 64 |if you w|ant to d|
|00002340| 6f 20 79 6f 75 72 20 6f | 77 6e 20 65 72 72 6f 72 |o your o|wn error|
|00002350| 20 68 61 6e 64 6c 69 6e | 67 2e 0a 58 2e 53 48 20 | handlin|g..X.SH |
|00002360| 22 53 45 45 20 41 4c 53 | 4f 22 0a 58 2e 42 52 20 |"SEE ALS|O".X.BR |
|00002370| 6d 61 6c 6c 6f 63 20 28 | 33 29 2c 0a 58 2e 42 52 |malloc (|3),.X.BR|
|00002380| 20 73 74 64 69 6f 20 28 | 33 53 29 0a 58 2e 53 48 | stdio (|3S).X.SH|
|00002390| 20 4e 4f 54 45 0a 58 2e | 4c 50 0a 58 22 6d 65 6d | NOTE.X.|LP.X"mem|
|000023a0| 6c 69 6e 74 6f 6b 2e 68 | 22 20 61 73 73 75 6d 65 |lintok.h|" assume|
|000023b0| 73 20 4e 55 4c 4c 20 69 | 73 20 64 65 66 69 6e 65 |s NULL i|s define|
|000023c0| 64 20 69 6e 20 3c 73 74 | 64 69 6f 2e 68 3e 20 28 |d in <st|dio.h> (|
|000023d0| 77 68 69 63 68 20 69 73 | 20 75 73 75 61 6c 6c 79 |which is| usually|
|000023e0| 20 74 68 65 20 63 61 73 | 65 29 2e 0a 58 2e 4c 50 | the cas|e)..X.LP|
|000023f0| 0a 58 49 74 20 61 6c 73 | 6f 20 61 73 73 75 6d 65 |.XIt als|o assume|
|00002400| 73 20 74 68 65 20 63 70 | 70 20 73 79 6d 62 6f 6c |s the cp|p symbol|
|00002410| 20 22 6c 69 6e 74 22 20 | 69 73 20 64 65 66 69 6e | "lint" |is defin|
|00002420| 65 64 20 77 68 65 6e 20 | 61 6e 64 20 6f 6e 6c 79 |ed when |and only|
|00002430| 20 77 68 65 6e 20 74 68 | 65 0a 58 63 6f 64 65 20 | when th|e.Xcode |
|00002440| 69 73 20 62 65 69 6e 67 | 20 70 61 73 73 65 64 20 |is being| passed |
|00002450| 74 68 72 6f 75 67 68 20 | 6c 69 6e 74 20 61 6e 64 |through |lint and|
|00002460| 20 6e 6f 74 20 67 65 6e | 65 72 61 74 69 6e 67 20 | not gen|erating |
|00002470| 72 65 61 6c 20 65 78 65 | 63 75 74 61 62 6c 65 20 |real exe|cutable |
|00002480| 63 6f 64 65 2e 0a 58 2e | 4c 50 0a 58 54 68 65 73 |code..X.|LP.XThes|
|00002490| 65 20 6d 61 63 72 6f 73 | 20 68 61 76 65 20 62 65 |e macros| have be|
|000024a0| 65 6e 20 74 65 73 74 65 | 64 20 75 6e 64 65 72 20 |en teste|d under |
|000024b0| 53 75 6e 4f 53 2c 20 48 | 50 2d 55 58 2c 20 61 6e |SunOS, H|P-UX, an|
|000024c0| 64 20 41 70 6f 6c 6c 6f | 20 44 4f 4d 41 49 4e 2f |d Apollo| DOMAIN/|
|000024d0| 49 58 2e 0a 58 2e 53 48 | 20 42 55 47 53 0a 58 2e |IX..X.SH| BUGS.X.|
|000024e0| 4c 50 0a 58 54 68 65 73 | 65 20 6d 61 63 72 6f 73 |LP.XThes|e macros|
|000024f0| 20 61 72 65 20 69 6e 74 | 65 6e 64 65 64 20 66 6f | are int|ended fo|
|00002500| 72 20 75 73 65 20 77 69 | 74 68 20 74 68 65 20 64 |r use wi|th the d|
|00002510| 79 6e 61 6d 69 63 0a 58 | 61 6c 6c 6f 63 61 74 69 |ynamic.X|allocati|
|00002520| 6f 6e 20 6f 66 20 73 69 | 6e 67 6c 65 20 65 6c 65 |on of si|ngle ele|
|00002530| 6d 65 6e 74 73 20 6f 66 | 20 66 69 78 65 64 20 73 |ments of| fixed s|
|00002540| 69 7a 65 20 28 69 2e 65 | 2e 20 73 74 72 75 63 74 |ize (i.e|. struct|
|00002550| 73 20 6f 72 20 74 79 70 | 65 64 65 66 73 29 0a 58 |s or typ|edefs).X|
|00002560| 6f 72 20 76 61 72 69 61 | 62 6c 79 2d 73 69 7a 65 |or varia|bly-size|
|00002570| 64 20 61 72 72 61 79 73 | 20 6f 66 20 73 61 6d 65 |d arrays| of same|
|00002580| 2e 0a 58 49 6e 20 74 68 | 65 20 61 75 74 68 6f 72 |..XIn th|e author|
|00002590| 27 73 20 65 78 70 65 72 | 69 65 6e 63 65 2c 20 74 |'s exper|ience, t|
|000025a0| 68 69 73 20 63 6f 76 65 | 72 73 20 6d 6f 73 74 20 |his cove|rs most |
|000025b0| 75 73 65 73 20 6f 66 20 | 74 68 65 0a 58 2e 49 52 |uses of |the.X.IR|
|000025c0| 20 5c 66 49 2a 61 6c 6c | 6f 63 5c 66 50 20 28 33 | \fI*all|oc\fP (3|
|000025d0| 29 0a 58 66 75 6e 63 74 | 69 6f 6e 73 2e 0a 58 54 |).Xfunct|ions..XT|
|000025e0| 68 65 20 6d 61 63 72 6f | 73 20 64 6f 20 6e 6f 74 |he macro|s do not|
|000025f0| 20 77 6f 72 6b 20 77 65 | 6c 6c 2c 20 68 6f 77 65 | work we|ll, howe|
|00002600| 76 65 72 2c 20 77 68 65 | 6e 20 63 72 65 61 74 69 |ver, whe|n creati|
|00002610| 6e 67 20 76 61 72 69 61 | 62 6c 79 2d 73 69 7a 65 |ng varia|bly-size|
|00002620| 64 20 73 69 6e 67 6c 65 | 0a 58 73 74 72 75 63 74 |d single|.Xstruct|
|00002630| 75 72 65 73 20 74 68 61 | 74 20 61 72 65 20 6e 6f |ures tha|t are no|
|00002640| 74 20 61 72 72 61 79 73 | 2e 0a 58 2e 4c 50 0a 58 |t arrays|..X.LP.X|
|00002650| 41 74 20 6c 65 61 73 74 | 20 6f 6e 65 20 76 65 72 |At least| one ver|
|00002660| 73 69 6f 6e 20 6f 66 0a | 58 2e 49 52 20 6c 69 6e |sion of.|X.IR lin|
|00002670| 74 20 28 31 29 0a 58 28 | 53 75 6e 4f 53 20 34 2e |t (1).X(|SunOS 4.|
|00002680| 30 29 20 63 6f 6d 70 6c | 61 69 6e 73 20 77 68 65 |0) compl|ains whe|
|00002690| 6e 20 74 68 65 73 65 20 | 6d 61 63 72 6f 73 0a 58 |n these |macros.X|
|000026a0| 61 72 65 20 75 73 65 64 | 20 77 69 74 68 20 22 76 |are used| with "v|
|000026b0| 6f 69 64 20 2a 22 20 70 | 6f 69 6e 74 65 72 73 2e |oid *" p|ointers.|
|000026c0| 0a 58 49 74 20 6e 65 65 | 64 6e 27 74 2e 0a 58 2e |.XIt nee|dn't..X.|
|000026d0| 4c 50 0a 58 41 70 6f 6c | 6c 6f 20 44 4f 4d 41 49 |LP.XApol|lo DOMAI|
|000026e0| 4e 2f 49 58 0a 58 2e 49 | 52 20 6c 69 6e 74 20 28 |N/IX.X.I|R lint (|
|000026f0| 31 29 0a 58 67 65 6e 65 | 72 61 74 65 73 20 73 65 |1).Xgene|rates se|
|00002700| 76 65 72 61 6c 20 62 6f | 67 75 73 20 28 49 20 62 |veral bo|gus (I b|
|00002710| 65 6c 69 65 76 65 29 20 | 63 6f 6d 70 6c 61 69 6e |elieve) |complain|
|00002720| 74 73 20 61 62 6f 75 74 | 20 74 68 65 20 64 65 66 |ts about| the def|
|00002730| 61 75 6c 74 20 65 78 63 | 65 70 74 69 6f 6e 0a 58 |ault exc|eption.X|
|00002740| 68 61 6e 64 6c 69 6e 67 | 20 6d 61 63 72 6f 2e 0a |handling| macro..|
|00002750| 58 2e 53 48 20 41 55 54 | 48 4f 52 0a 58 2e 4c 50 |X.SH AUT|HOR.X.LP|
|00002760| 0a 58 42 6f 62 20 4c 65 | 77 69 73 20 28 62 6f 62 |.XBob Le|wis (bob|
|00002770| 6c 40 74 65 73 73 69 2e | 75 75 63 70 29 20 70 72 |l@tessi.|uucp) pr|
|00002780| 6f 64 75 63 65 64 20 74 | 68 65 73 65 20 6d 61 63 |oduced t|hese mac|
|00002790| 72 6f 73 20 75 73 69 6e | 67 20 68 69 73 20 6f 77 |ros usin|g his ow|
|000027a0| 6e 0a 58 72 65 73 6f 75 | 72 63 65 73 20 61 6e 64 |n.Xresou|rces and|
|000027b0| 20 68 65 72 65 62 79 20 | 72 65 6c 65 61 73 65 73 | hereby |releases|
|000027c0| 20 74 68 65 6d 20 74 6f | 20 74 68 65 20 70 75 62 | them to| the pub|
|000027d0| 6c 69 63 20 64 6f 6d 61 | 69 6e 2e 0a 58 54 68 65 |lic doma|in..XThe|
|000027e0| 20 61 75 74 68 6f 72 20 | 77 69 6c 6c 20 6e 6f 74 | author |will not|
|000027f0| 20 62 65 20 68 65 6c 64 | 20 72 65 73 70 6f 6e 73 | be held| respons|
|00002800| 69 62 6c 65 20 66 6f 72 | 20 74 68 65 69 72 20 75 |ible for| their u|
|00002810| 73 65 2c 20 6d 69 73 75 | 73 65 2c 0a 58 61 62 75 |se, misu|se,.Xabu|
|00002820| 73 65 2c 20 6f 72 20 61 | 6e 79 20 64 61 6d 61 67 |se, or a|ny damag|
|00002830| 65 73 20 61 72 69 73 69 | 6e 67 20 66 72 6f 6d 20 |es arisi|ng from |
|00002840| 73 61 6d 65 2e 0a 45 4e | 44 5f 4f 46 5f 6d 65 6d |same..EN|D_OF_mem|
|00002850| 6c 69 6e 74 6f 6b 2e 33 | 0a 69 66 20 74 65 73 74 |lintok.3|.if test|
|00002860| 20 34 37 30 36 20 2d 6e | 65 20 60 77 63 20 2d 63 | 4706 -n|e `wc -c|
|00002870| 20 3c 6d 65 6d 6c 69 6e | 74 6f 6b 2e 33 60 3b 20 | <memlin|tok.3`; |
|00002880| 74 68 65 6e 0a 20 20 20 | 20 65 63 68 6f 20 73 68 |then. | echo sh|
|00002890| 61 72 3a 20 5c 22 6d 65 | 6d 6c 69 6e 74 6f 6b 2e |ar: \"me|mlintok.|
|000028a0| 33 5c 22 20 75 6e 70 61 | 63 6b 65 64 20 77 69 74 |3\" unpa|cked wit|
|000028b0| 68 20 77 72 6f 6e 67 20 | 73 69 7a 65 21 0a 66 69 |h wrong |size!.fi|
|000028c0| 0a 23 20 65 6e 64 20 6f | 66 20 6f 76 65 72 77 72 |.# end o|f overwr|
|000028d0| 69 74 69 6e 67 20 63 68 | 65 63 6b 0a 66 69 0a 69 |iting ch|eck.fi.i|
|000028e0| 66 20 74 65 73 74 20 2d | 66 20 6d 65 6d 6c 69 6e |f test -|f memlin|
|000028f0| 74 6f 6b 2e 68 20 2d 61 | 20 22 24 7b 31 7d 22 20 |tok.h -a| "${1}" |
|00002900| 21 3d 20 22 2d 63 22 20 | 3b 20 74 68 65 6e 20 0a |!= "-c" |; then .|
|00002910| 20 20 65 63 68 6f 20 73 | 68 61 72 3a 20 57 69 6c | echo s|har: Wil|
|00002920| 6c 20 6e 6f 74 20 6f 76 | 65 72 2d 77 72 69 74 65 |l not ov|er-write|
|00002930| 20 65 78 69 73 74 69 6e | 67 20 66 69 6c 65 20 5c | existin|g file \|
|00002940| 22 6d 65 6d 6c 69 6e 74 | 6f 6b 2e 68 5c 22 0a 65 |"memlint|ok.h\".e|
|00002950| 6c 73 65 0a 65 63 68 6f | 20 73 68 61 72 3a 20 45 |lse.echo| shar: E|
|00002960| 78 74 72 61 63 74 69 6e | 67 20 5c 22 6d 65 6d 6c |xtractin|g \"meml|
|00002970| 69 6e 74 6f 6b 2e 68 5c | 22 20 5c 28 32 39 38 36 |intok.h\|" \(2986|
|00002980| 20 63 68 61 72 61 63 74 | 65 72 73 5c 29 0a 73 65 | charact|ers\).se|
|00002990| 64 20 22 73 2f 5e 58 2f | 2f 22 20 3e 6d 65 6d 6c |d "s/^X/|/" >meml|
|000029a0| 69 6e 74 6f 6b 2e 68 20 | 3c 3c 27 45 4e 44 5f 4f |intok.h |<<'END_O|
|000029b0| 46 5f 6d 65 6d 6c 69 6e | 74 6f 6b 2e 68 27 0a 58 |F_memlin|tok.h'.X|
|000029c0| 23 69 66 6e 64 65 66 20 | 49 4e 43 4c 55 44 45 44 |#ifndef |INCLUDED|
|000029d0| 5f 4c 49 4e 54 4f 4b 0a | 58 0a 58 2f 2a 20 24 48 |_LINTOK.|X.X/* $H|
|000029e0| 65 61 64 65 72 3a 20 6d | 65 6d 6c 69 6e 74 6f 6b |eader: m|emlintok|
|000029f0| 2e 68 2c 76 20 31 2e 33 | 20 38 39 2f 30 35 2f 30 |.h,v 1.3| 89/05/0|
|00002a00| 32 20 31 35 3a 30 31 3a | 34 33 20 62 6f 62 6c 20 |2 15:01:|43 bobl |
|00002a10| 4c 6f 63 6b 65 64 20 24 | 20 2a 2f 0a 58 0a 58 2f |Locked $| */.X.X/|
|00002a20| 2a 0a 58 20 2a 09 54 68 | 65 73 65 20 64 65 66 69 |*.X *.Th|ese defi|
|00002a30| 6e 69 74 69 6f 6e 73 20 | 73 74 6f 70 20 6c 69 6e |nitions |stop lin|
|00002a40| 74 20 66 72 6f 6d 20 63 | 6f 6d 70 6c 61 69 6e 69 |t from c|omplaini|
|00002a50| 6e 67 20 61 62 6f 75 74 | 20 6d 61 6c 6c 6f 63 2c |ng about| malloc,|
|00002a60| 20 63 61 6c 6c 6f 63 2c | 0a 58 20 2a 09 72 65 61 | calloc,|.X *.rea|
|00002a70| 6c 6c 6f 63 2c 20 61 6e | 64 20 66 72 65 65 20 77 |lloc, an|d free w|
|00002a80| 68 69 6c 65 20 61 74 20 | 74 68 65 20 73 61 6d 65 |hile at |the same|
|00002a90| 20 74 69 6d 65 20 70 65 | 72 66 6f 72 6d 69 6e 67 | time pe|rforming|
|00002aa0| 20 63 68 65 63 6b 73 20 | 6f 66 0a 58 20 2a 09 74 | checks |of.X *.t|
|00002ab0| 68 65 69 72 20 61 72 67 | 75 6d 65 6e 74 73 2e 20 |heir arg|uments. |
|00002ac0| 20 53 65 65 20 74 68 65 | 20 6d 65 6d 6c 69 6e 74 | See the| memlint|
|00002ad0| 6f 6b 28 33 29 20 6d 61 | 6e 20 70 61 67 65 20 66 |ok(3) ma|n page f|
|00002ae0| 6f 72 20 6d 6f 72 65 20 | 64 65 74 61 69 6c 73 2e |or more |details.|
|00002af0| 0a 58 20 2a 0a 58 20 2a | 09 42 6f 62 20 4c 65 77 |.X *.X *|.Bob Lew|
|00002b00| 69 73 20 28 62 6f 62 6c | 40 74 65 73 73 69 2e 75 |is (bobl|@tessi.u|
|00002b10| 75 63 70 29 20 70 72 6f | 64 75 63 65 64 20 74 68 |ucp) pro|duced th|
|00002b20| 65 73 65 20 6d 61 63 72 | 6f 73 20 75 73 69 6e 67 |ese macr|os using|
|00002b30| 20 68 69 73 20 6f 77 6e | 0a 58 20 2a 09 72 65 73 | his own|.X *.res|
|00002b40| 6f 75 72 63 65 73 20 61 | 6e 64 20 68 65 72 65 62 |ources a|nd hereb|
|00002b50| 79 20 72 65 6c 65 61 73 | 65 73 20 74 68 65 6d 20 |y releas|es them |
|00002b60| 74 6f 20 74 68 65 20 70 | 75 62 6c 69 63 20 64 6f |to the p|ublic do|
|00002b70| 6d 61 69 6e 2e 0a 58 20 | 2a 09 54 68 65 20 61 75 |main..X |*.The au|
|00002b80| 74 68 6f 72 20 77 69 6c | 6c 20 6e 6f 74 20 62 65 |thor wil|l not be|
|00002b90| 20 68 65 6c 64 20 72 65 | 73 70 6f 6e 73 69 62 6c | held re|sponsibl|
|00002ba0| 65 20 66 6f 72 20 74 68 | 65 69 72 20 75 73 65 2c |e for th|eir use,|
|00002bb0| 20 6d 69 73 75 73 65 2c | 0a 58 20 2a 09 61 62 75 | misuse,|.X *.abu|
|00002bc0| 73 65 2c 20 6f 72 20 61 | 6e 79 20 64 61 6d 61 67 |se, or a|ny damag|
|00002bd0| 65 73 20 61 72 69 73 69 | 6e 67 20 66 72 6f 6d 20 |es arisi|ng from |
|00002be0| 73 61 6d 65 2e 0a 58 20 | 2a 2f 0a 58 0a 58 23 69 |same..X |*/.X.X#i|
|00002bf0| 66 6e 64 65 66 20 4e 55 | 4c 4c 0a 58 23 69 6e 63 |fndef NU|LL.X#inc|
|00002c00| 6c 75 64 65 20 3c 73 74 | 64 69 6f 2e 68 3e 0a 58 |lude <st|dio.h>.X|
|00002c10| 23 65 6e 64 69 66 0a 58 | 0a 58 65 78 74 65 72 6e |#endif.X|.Xextern|
|00002c20| 20 63 68 61 72 20 2a 63 | 61 6c 6c 6f 63 28 29 3b | char *c|alloc();|
|00002c30| 0a 58 23 69 66 64 65 66 | 20 6c 69 6e 74 0a 58 23 |.X#ifdef| lint.X#|
|00002c40| 64 65 66 69 6e 65 20 43 | 41 4c 4c 4f 43 5f 4c 49 |define C|ALLOC_LI|
|00002c50| 4e 54 4f 4b 28 70 74 72 | 2c 20 6e 65 6c 65 6d 2c |NTOK(ptr|, nelem,|
|00002c60| 20 74 79 70 65 29 20 5c | 0a 58 09 63 61 6c 6c 6f | type) \|.X.callo|
|00002c70| 63 28 28 70 74 72 20 3d | 20 28 74 79 70 65 20 2a |c((ptr =| (type *|
|00002c80| 29 20 4e 55 4c 4c 2c 20 | 28 75 6e 73 69 67 6e 65 |) NULL, |(unsigne|
|00002c90| 64 29 20 28 6e 65 6c 65 | 6d 29 29 2c 20 28 75 6e |d) (nele|m)), (un|
|00002ca0| 73 69 67 6e 65 64 29 20 | 73 69 7a 65 6f 66 28 74 |signed) |sizeof(t|
|00002cb0| 79 70 65 29 29 0a 58 23 | 65 6c 73 65 0a 58 23 64 |ype)).X#|else.X#d|
|00002cc0| 65 66 69 6e 65 20 43 41 | 4c 4c 4f 43 5f 4c 49 4e |efine CA|LLOC_LIN|
|00002cd0| 54 4f 4b 28 70 74 72 2c | 20 6e 65 6c 65 6d 2c 20 |TOK(ptr,| nelem, |
|00002ce0| 74 79 70 65 29 20 5c 0a | 58 09 28 70 74 72 20 3d |type) \.|X.(ptr =|
|00002cf0| 20 28 74 79 70 65 20 2a | 29 20 63 61 6c 6c 6f 63 | (type *|) calloc|
|00002d00| 28 28 75 6e 73 69 67 6e | 65 64 29 20 28 6e 65 6c |((unsign|ed) (nel|
|00002d10| 65 6d 29 2c 20 28 75 6e | 73 69 67 6e 65 64 29 20 |em), (un|signed) |
|00002d20| 73 69 7a 65 6f 66 28 74 | 79 70 65 29 29 29 0a 58 |sizeof(t|ype))).X|
|00002d30| 23 65 6e 64 69 66 0a 58 | 0a 58 65 78 74 65 72 6e |#endif.X|.Xextern|
|00002d40| 20 63 68 61 72 20 2a 6d | 61 6c 6c 6f 63 28 29 3b | char *m|alloc();|
|00002d50| 0a 58 23 69 66 64 65 66 | 20 6c 69 6e 74 0a 58 23 |.X#ifdef| lint.X#|
|00002d60| 64 65 66 69 6e 65 20 4d | 41 4c 4c 4f 43 5f 4c 49 |define M|ALLOC_LI|
|00002d70| 4e 54 4f 4b 28 70 74 72 | 2c 20 6e 65 6c 65 6d 2c |NTOK(ptr|, nelem,|
|00002d80| 20 74 79 70 65 29 20 5c | 0a 58 09 6d 61 6c 6c 6f | type) \|.X.mallo|
|00002d90| 63 28 28 70 74 72 20 3d | 20 28 74 79 70 65 20 2a |c((ptr =| (type *|
|00002da0| 29 20 4e 55 4c 4c 2c 20 | 28 75 6e 73 69 67 6e 65 |) NULL, |(unsigne|
|00002db0| 64 29 20 28 28 6e 65 6c | 65 6d 29 20 2a 20 73 69 |d) ((nel|em) * si|
|00002dc0| 7a 65 6f 66 28 74 79 70 | 65 29 29 29 29 0a 58 23 |zeof(typ|e)))).X#|
|00002dd0| 65 6c 73 65 0a 58 23 64 | 65 66 69 6e 65 20 4d 41 |else.X#d|efine MA|
|00002de0| 4c 4c 4f 43 5f 4c 49 4e | 54 4f 4b 28 70 74 72 2c |LLOC_LIN|TOK(ptr,|
|00002df0| 20 6e 65 6c 65 6d 2c 20 | 74 79 70 65 29 20 5c 0a | nelem, |type) \.|
|00002e00| 58 09 28 70 74 72 20 3d | 20 28 74 79 70 65 20 2a |X.(ptr =| (type *|
|00002e10| 29 20 6d 61 6c 6c 6f 63 | 28 28 75 6e 73 69 67 6e |) malloc|((unsign|
|00002e20| 65 64 29 20 28 28 6e 65 | 6c 65 6d 29 20 2a 20 73 |ed) ((ne|lem) * s|
|00002e30| 69 7a 65 6f 66 28 74 79 | 70 65 29 29 29 29 0a 58 |izeof(ty|pe)))).X|
|00002e40| 23 65 6e 64 69 66 0a 58 | 0a 58 65 78 74 65 72 6e |#endif.X|.Xextern|
|00002e50| 20 63 68 61 72 20 2a 72 | 65 61 6c 6c 6f 63 28 29 | char *r|ealloc()|
|00002e60| 3b 0a 58 23 69 66 64 65 | 66 20 6c 69 6e 74 0a 58 |;.X#ifde|f lint.X|
|00002e70| 23 64 65 66 69 6e 65 20 | 52 45 41 4c 4c 4f 43 5f |#define |REALLOC_|
|00002e80| 4c 49 4e 54 4f 4b 28 70 | 74 72 2c 20 6e 65 6c 65 |LINTOK(p|tr, nele|
|00002e90| 6d 2c 20 74 79 70 65 29 | 20 5c 0a 58 09 72 65 61 |m, type)| \.X.rea|
|00002ea0| 6c 6c 6f 63 28 20 5c 0a | 58 09 09 28 70 74 72 20 |lloc( \.|X..(ptr |
|00002eb0| 3d 20 28 74 79 70 65 20 | 2a 29 20 4e 55 4c 4c 2c |= (type |*) NULL,|
|00002ec0| 20 28 63 68 61 72 20 2a | 29 20 4e 55 4c 4c 29 2c | (char *|) NULL),|
|00002ed0| 20 5c 0a 58 09 09 28 75 | 6e 73 69 67 6e 65 64 29 | \.X..(u|nsigned)|
|00002ee0| 20 28 28 6e 65 6c 65 6d | 29 20 2a 20 73 69 7a 65 | ((nelem|) * size|
|00002ef0| 6f 66 28 74 79 70 65 29 | 29 29 0a 58 23 65 6c 73 |of(type)|)).X#els|
|00002f00| 65 0a 58 23 64 65 66 69 | 6e 65 20 52 45 41 4c 4c |e.X#defi|ne REALL|
|00002f10| 4f 43 5f 4c 49 4e 54 4f | 4b 28 70 74 72 2c 20 6e |OC_LINTO|K(ptr, n|
|00002f20| 65 6c 65 6d 2c 20 74 79 | 70 65 29 20 5c 0a 58 09 |elem, ty|pe) \.X.|
|00002f30| 28 70 74 72 20 3d 20 28 | 74 79 70 65 20 2a 29 20 |(ptr = (|type *) |
|00002f40| 72 65 61 6c 6c 6f 63 28 | 20 5c 0a 58 09 09 28 63 |realloc(| \.X..(c|
|00002f50| 68 61 72 20 2a 29 20 70 | 74 72 2c 20 5c 0a 58 09 |har *) p|tr, \.X.|
|00002f60| 09 28 75 6e 73 69 67 6e | 65 64 29 20 28 28 6e 65 |.(unsign|ed) ((ne|
|00002f70| 6c 65 6d 29 20 2a 20 73 | 69 7a 65 6f 66 28 74 79 |lem) * s|izeof(ty|
|00002f80| 70 65 29 29 29 29 0a 58 | 23 65 6e 64 69 66 0a 58 |pe)))).X|#endif.X|
|00002f90| 0a 58 2f 2a 20 63 6f 6d | 6d 6f 6e 20 75 73 65 20 |.X/* com|mon use |
|00002fa0| 6f 66 20 6d 61 6c 6c 6f | 63 2f 72 65 61 6c 6c 6f |of mallo|c/reallo|
|00002fb0| 63 20 2d 2d 20 75 73 65 | 20 69 74 20 6f 72 20 64 |c -- use| it or d|
|00002fc0| 6f 6e 27 74 20 75 73 65 | 20 69 74 20 2a 2f 0a 58 |on't use| it */.X|
|00002fd0| 23 64 65 66 69 6e 65 20 | 4d 52 5f 41 4c 4c 4f 43 |#define |MR_ALLOC|
|00002fe0| 5f 4c 49 4e 54 4f 4b 28 | 70 74 72 2c 20 6e 65 6c |_LINTOK(|ptr, nel|
|00002ff0| 65 6d 2c 20 74 79 70 65 | 29 20 5c 0a 58 09 28 20 |em, type|) \.X.( |
|00003000| 28 70 74 72 29 20 3d 3d | 20 4e 55 4c 4c 20 5c 0a |(ptr) ==| NULL \.|
|00003010| 58 09 09 3f 20 4d 41 4c | 4c 4f 43 5f 4c 49 4e 54 |X..? MAL|LOC_LINT|
|00003020| 4f 4b 28 70 74 72 2c 20 | 28 6e 65 6c 65 6d 29 2c |OK(ptr, |(nelem),|
|00003030| 20 74 79 70 65 29 20 5c | 0a 58 09 09 3a 20 52 45 | type) \|.X..: RE|
|00003040| 41 4c 4c 4f 43 5f 4c 49 | 4e 54 4f 4b 28 70 74 72 |ALLOC_LI|NTOK(ptr|
|00003050| 2c 20 28 6e 65 6c 65 6d | 29 2c 20 74 79 70 65 29 |, (nelem|), type)|
|00003060| 20 29 0a 58 0a 58 2f 2a | 0a 58 20 2a 09 54 68 65 | ).X.X/*|.X *.The|
|00003070| 73 65 20 6e 65 78 74 20 | 6d 61 63 72 6f 73 20 69 |se next |macros i|
|00003080| 6e 76 6f 6b 65 20 43 41 | 4c 4c 4f 43 5f 4c 49 4e |nvoke CA|LLOC_LIN|
|00003090| 54 4f 4b 2c 20 4d 41 4c | 4c 4f 43 5f 4c 49 4e 54 |TOK, MAL|LOC_LINT|
|000030a0| 4f 4b 2c 20 52 45 41 4c | 4c 4f 43 5f 4c 49 4e 54 |OK, REAL|LOC_LINT|
|000030b0| 4f 4b 2c 0a 58 20 2a 09 | 61 6e 64 20 4d 52 5f 41 |OK,.X *.|and MR_A|
|000030c0| 4c 4c 4f 43 5f 4c 49 4e | 54 4f 4b 20 77 69 74 68 |LLOC_LIN|TOK with|
|000030d0| 20 61 6e 20 65 72 72 6f | 72 20 65 78 69 74 20 69 | an erro|r exit i|
|000030e0| 66 20 74 68 65 79 20 66 | 61 69 6c 2e 0a 58 20 2a |f they f|ail..X *|
|000030f0| 0a 58 20 2a 09 49 66 20 | 79 6f 75 20 77 61 6e 74 |.X *.If |you want|
|00003100| 20 74 6f 20 68 61 6e 64 | 6c 65 20 79 6f 75 72 20 | to hand|le your |
|00003110| 6f 77 6e 20 6d 65 6d 6f | 72 79 20 61 6c 6c 6f 63 |own memo|ry alloc|
|00003120| 61 74 69 6f 6e 20 65 72 | 72 6f 72 73 2c 20 6a 75 |ation er|rors, ju|
|00003130| 73 74 0a 58 20 2a 09 22 | 23 75 6e 64 65 66 20 45 |st.X *."|#undef E|
|00003140| 52 52 4f 52 5f 45 58 49 | 54 5f 4c 49 4e 54 4f 4b |RROR_EXI|T_LINTOK|
|00003150| 22 20 61 6e 64 20 64 65 | 66 69 6e 65 20 79 6f 75 |" and de|fine you|
|00003160| 72 20 6f 77 6e 2e 0a 58 | 20 2a 2f 0a 58 23 64 65 |r own..X| */.X#de|
|00003170| 66 69 6e 65 20 45 52 52 | 4f 52 5f 45 58 49 54 5f |fine ERR|OR_EXIT_|
|00003180| 4c 49 4e 54 4f 4b 28 6e | 65 6c 65 6d 2c 20 73 69 |LINTOK(n|elem, si|
|00003190| 7a 65 29 20 5c 0a 58 09 | 7b 20 5c 0a 58 09 09 28 |ze) \.X.|{ \.X..(|
|000031a0| 76 6f 69 64 29 20 66 70 | 72 69 6e 74 66 28 73 74 |void) fp|rintf(st|
|000031b0| 64 65 72 72 2c 20 5c 0a | 58 09 09 09 22 4d 65 6d |derr, \.|X..."Mem|
|000031c0| 6f 72 79 20 61 6c 6c 6f | 63 61 74 69 6f 6e 20 6f |ory allo|cation o|
|000031d0| 66 20 25 64 20 2a 20 25 | 64 20 62 79 74 65 73 20 |f %d * %|d bytes |
|000031e0| 6f 6e 20 6c 69 6e 65 20 | 25 64 20 6f 66 20 5c 22 |on line |%d of \"|
|000031f0| 25 73 5c 22 20 66 61 69 | 6c 65 64 2e 5c 6e 22 2c |%s\" fai|led.\n",|
|00003200| 20 5c 0a 58 09 09 09 28 | 6e 65 6c 65 6d 29 2c 20 | \.X...(|nelem), |
|00003210| 28 73 69 7a 65 29 2c 20 | 5f 5f 4c 49 4e 45 5f 5f |(size), |__LINE__|
|00003220| 2c 20 5f 5f 46 49 4c 45 | 5f 5f 29 3b 20 5c 0a 58 |, __FILE|__); \.X|
|00003230| 09 09 65 78 69 74 28 31 | 29 3b 20 5c 0a 58 09 7d |..exit(1|); \.X.}|
|00003240| 0a 58 0a 58 23 64 65 66 | 69 6e 65 20 43 41 4c 4c |.X.X#def|ine CALL|
|00003250| 4f 43 5f 4f 52 5f 45 4c | 53 45 5f 4c 49 4e 54 4f |OC_OR_EL|SE_LINTO|
|00003260| 4b 28 70 74 72 2c 20 6e | 65 6c 65 6d 2c 20 74 79 |K(ptr, n|elem, ty|
|00003270| 70 65 29 20 5c 0a 58 09 | 7b 20 5c 0a 58 09 09 69 |pe) \.X.|{ \.X..i|
|00003280| 66 20 28 43 41 4c 4c 4f | 43 5f 4c 49 4e 54 4f 4b |f (CALLO|C_LINTOK|
|00003290| 28 70 74 72 2c 20 28 6e | 65 6c 65 6d 29 2c 20 74 |(ptr, (n|elem), t|
|000032a0| 79 70 65 29 20 3d 3d 20 | 4e 55 4c 4c 29 20 5c 0a |ype) == |NULL) \.|
|000032b0| 58 09 09 09 45 52 52 4f | 52 5f 45 58 49 54 5f 4c |X...ERRO|R_EXIT_L|
|000032c0| 49 4e 54 4f 4b 28 28 6e | 65 6c 65 6d 29 2c 20 73 |INTOK((n|elem), s|
|000032d0| 69 7a 65 6f 66 28 74 79 | 70 65 29 29 3b 20 5c 0a |izeof(ty|pe)); \.|
|000032e0| 58 09 7d 0a 58 0a 58 23 | 64 65 66 69 6e 65 20 4d |X.}.X.X#|define M|
|000032f0| 41 4c 4c 4f 43 5f 4f 52 | 5f 45 4c 53 45 5f 4c 49 |ALLOC_OR|_ELSE_LI|
|00003300| 4e 54 4f 4b 28 70 74 72 | 2c 20 6e 65 6c 65 6d 2c |NTOK(ptr|, nelem,|
|00003310| 20 74 79 70 65 29 20 5c | 0a 58 09 7b 20 5c 0a 58 | type) \|.X.{ \.X|
|00003320| 09 09 69 66 20 28 4d 41 | 4c 4c 4f 43 5f 4c 49 4e |..if (MA|LLOC_LIN|
|00003330| 54 4f 4b 28 70 74 72 2c | 20 28 6e 65 6c 65 6d 29 |TOK(ptr,| (nelem)|
|00003340| 2c 20 74 79 70 65 29 20 | 3d 3d 20 4e 55 4c 4c 29 |, type) |== NULL)|
|00003350| 20 5c 0a 58 09 09 09 45 | 52 52 4f 52 5f 45 58 49 | \.X...E|RROR_EXI|
|00003360| 54 5f 4c 49 4e 54 4f 4b | 28 28 6e 65 6c 65 6d 29 |T_LINTOK|((nelem)|
|00003370| 2c 20 73 69 7a 65 6f 66 | 28 74 79 70 65 29 29 3b |, sizeof|(type));|
|00003380| 20 5c 0a 58 09 7d 0a 58 | 0a 58 23 64 65 66 69 6e | \.X.}.X|.X#defin|
|00003390| 65 20 52 45 41 4c 4c 4f | 43 5f 4f 52 5f 45 4c 53 |e REALLO|C_OR_ELS|
|000033a0| 45 5f 4c 49 4e 54 4f 4b | 28 70 74 72 2c 20 6e 65 |E_LINTOK|(ptr, ne|
|000033b0| 6c 65 6d 2c 20 74 79 70 | 65 29 20 5c 0a 58 09 7b |lem, typ|e) \.X.{|
|000033c0| 20 5c 0a 58 09 09 69 66 | 20 28 52 45 41 4c 4c 4f | \.X..if| (REALLO|
|000033d0| 43 5f 4c 49 4e 54 4f 4b | 28 70 74 72 2c 20 28 6e |C_LINTOK|(ptr, (n|
|000033e0| 65 6c 65 6d 29 2c 20 74 | 79 70 65 29 20 3d 3d 20 |elem), t|ype) == |
|000033f0| 4e 55 4c 4c 29 20 5c 0a | 58 09 09 09 45 52 52 4f |NULL) \.|X...ERRO|
|00003400| 52 5f 45 58 49 54 5f 4c | 49 4e 54 4f 4b 28 28 6e |R_EXIT_L|INTOK((n|
|00003410| 65 6c 65 6d 29 2c 20 73 | 69 7a 65 6f 66 28 74 79 |elem), s|izeof(ty|
|00003420| 70 65 29 29 3b 20 5c 0a | 58 09 7d 0a 58 0a 58 23 |pe)); \.|X.}.X.X#|
|00003430| 64 65 66 69 6e 65 20 4d | 52 5f 41 4c 4c 4f 43 5f |define M|R_ALLOC_|
|00003440| 4f 52 5f 45 4c 53 45 5f | 4c 49 4e 54 4f 4b 28 70 |OR_ELSE_|LINTOK(p|
|00003450| 74 72 2c 20 6e 65 6c 65 | 6d 2c 20 74 79 70 65 29 |tr, nele|m, type)|
|00003460| 20 5c 0a 58 09 7b 20 5c | 0a 58 09 09 69 66 20 28 | \.X.{ \|.X..if (|
|00003470| 4d 52 5f 41 4c 4c 4f 43 | 5f 4c 49 4e 54 4f 4b 28 |MR_ALLOC|_LINTOK(|
|00003480| 70 74 72 2c 20 28 6e 65 | 6c 65 6d 29 2c 20 74 79 |ptr, (ne|lem), ty|
|00003490| 70 65 29 20 3d 3d 20 4e | 55 4c 4c 29 20 5c 0a 58 |pe) == N|ULL) \.X|
|000034a0| 09 09 09 45 52 52 4f 52 | 5f 45 58 49 54 5f 4c 49 |...ERROR|_EXIT_LI|
|000034b0| 4e 54 4f 4b 28 28 6e 65 | 6c 65 6d 29 2c 20 73 69 |NTOK((ne|lem), si|
|000034c0| 7a 65 6f 66 28 74 79 70 | 65 29 29 3b 20 5c 0a 58 |zeof(typ|e)); \.X|
|000034d0| 09 7d 0a 58 0a 58 65 78 | 74 65 72 6e 20 66 72 65 |.}.X.Xex|tern fre|
|000034e0| 65 28 29 3b 0a 58 23 69 | 66 64 65 66 20 6c 69 6e |e();.X#i|fdef lin|
|000034f0| 74 0a 58 23 64 65 66 69 | 6e 65 20 46 52 45 45 5f |t.X#defi|ne FREE_|
|00003500| 4c 49 4e 54 4f 4b 28 70 | 74 72 29 20 5c 0a 58 09 |LINTOK(p|tr) \.X.|
|00003510| 66 72 65 65 28 28 70 74 | 72 20 3d 20 4e 55 4c 4c |free((pt|r = NULL|
|00003520| 2c 20 28 63 68 61 72 20 | 2a 29 20 4e 55 4c 4c 29 |, (char |*) NULL)|
|00003530| 29 0a 58 23 65 6c 73 65 | 0a 58 23 64 65 66 69 6e |).X#else|.X#defin|
|00003540| 65 20 46 52 45 45 5f 4c | 49 4e 54 4f 4b 28 70 74 |e FREE_L|INTOK(pt|
|00003550| 72 29 20 5c 0a 58 09 66 | 72 65 65 28 28 63 68 61 |r) \.X.f|ree((cha|
|00003560| 72 20 2a 29 20 70 74 72 | 29 0a 58 23 65 6e 64 69 |r *) ptr|).X#endi|
|00003570| 66 0a 58 0a 58 2f 2a 20 | 57 65 20 63 6f 75 6c 64 |f.X.X/* |We could|
|00003580| 20 68 61 76 65 20 61 20 | 22 43 46 52 45 45 5f 4c | have a |"CFREE_L|
|00003590| 49 4e 54 4f 4b 22 2c 20 | 62 75 74 20 77 68 61 74 |INTOK", |but what|
|000035a0| 27 73 20 74 68 65 20 70 | 6f 69 6e 74 3f 20 2a 2f |'s the p|oint? */|
|000035b0| 0a 58 0a 58 23 64 65 66 | 69 6e 65 20 49 4e 43 4c |.X.X#def|ine INCL|
|000035c0| 55 44 45 44 5f 4c 49 4e | 54 4f 4b 0a 58 23 65 6e |UDED_LIN|TOK.X#en|
|000035d0| 64 69 66 0a 58 0a 45 4e | 44 5f 4f 46 5f 6d 65 6d |dif.X.EN|D_OF_mem|
|000035e0| 6c 69 6e 74 6f 6b 2e 68 | 0a 69 66 20 74 65 73 74 |lintok.h|.if test|
|000035f0| 20 32 39 38 36 20 2d 6e | 65 20 60 77 63 20 2d 63 | 2986 -n|e `wc -c|
|00003600| 20 3c 6d 65 6d 6c 69 6e | 74 6f 6b 2e 68 60 3b 20 | <memlin|tok.h`; |
|00003610| 74 68 65 6e 0a 20 20 20 | 20 65 63 68 6f 20 73 68 |then. | echo sh|
|00003620| 61 72 3a 20 5c 22 6d 65 | 6d 6c 69 6e 74 6f 6b 2e |ar: \"me|mlintok.|
|00003630| 68 5c 22 20 75 6e 70 61 | 63 6b 65 64 20 77 69 74 |h\" unpa|cked wit|
|00003640| 68 20 77 72 6f 6e 67 20 | 73 69 7a 65 21 0a 66 69 |h wrong |size!.fi|
|00003650| 0a 23 20 65 6e 64 20 6f | 66 20 6f 76 65 72 77 72 |.# end o|f overwr|
|00003660| 69 74 69 6e 67 20 63 68 | 65 63 6b 0a 66 69 0a 69 |iting ch|eck.fi.i|
|00003670| 66 20 74 65 73 74 20 2d | 66 20 74 5f 6d 65 6d 6c |f test -|f t_meml|
|00003680| 69 6e 74 6f 6b 2e 63 20 | 2d 61 20 22 24 7b 31 7d |intok.c |-a "${1}|
|00003690| 22 20 21 3d 20 22 2d 63 | 22 20 3b 20 74 68 65 6e |" != "-c|" ; then|
|000036a0| 20 0a 20 20 65 63 68 6f | 20 73 68 61 72 3a 20 57 | . echo| shar: W|
|000036b0| 69 6c 6c 20 6e 6f 74 20 | 6f 76 65 72 2d 77 72 69 |ill not |over-wri|
|000036c0| 74 65 20 65 78 69 73 74 | 69 6e 67 20 66 69 6c 65 |te exist|ing file|
|000036d0| 20 5c 22 74 5f 6d 65 6d | 6c 69 6e 74 6f 6b 2e 63 | \"t_mem|lintok.c|
|000036e0| 5c 22 0a 65 6c 73 65 0a | 65 63 68 6f 20 73 68 61 |\".else.|echo sha|
|000036f0| 72 3a 20 45 78 74 72 61 | 63 74 69 6e 67 20 5c 22 |r: Extra|cting \"|
|00003700| 74 5f 6d 65 6d 6c 69 6e | 74 6f 6b 2e 63 5c 22 20 |t_memlin|tok.c\" |
|00003710| 5c 28 31 34 33 38 20 63 | 68 61 72 61 63 74 65 72 |\(1438 c|haracter|
|00003720| 73 5c 29 0a 73 65 64 20 | 22 73 2f 5e 58 2f 2f 22 |s\).sed |"s/^X//"|
|00003730| 20 3e 74 5f 6d 65 6d 6c | 69 6e 74 6f 6b 2e 63 20 | >t_meml|intok.c |
|00003740| 3c 3c 27 45 4e 44 5f 4f | 46 5f 74 5f 6d 65 6d 6c |<<'END_O|F_t_meml|
|00003750| 69 6e 74 6f 6b 2e 63 27 | 0a 58 2f 2a 20 24 48 65 |intok.c'|.X/* $He|
|00003760| 61 64 65 72 3a 20 74 5f | 6d 65 6d 6c 69 6e 74 6f |ader: t_|memlinto|
|00003770| 6b 2e 63 2c 76 20 31 2e | 33 20 38 39 2f 30 35 2f |k.c,v 1.|3 89/05/|
|00003780| 30 32 20 31 35 3a 30 37 | 3a 30 38 20 62 6f 62 6c |02 15:07|:08 bobl|
|00003790| 20 45 78 70 20 24 20 2a | 2f 0a 58 0a 58 23 69 6e | Exp $ *|/.X.X#in|
|000037a0| 63 6c 75 64 65 20 3c 73 | 74 64 69 6f 2e 68 3e 0a |clude <s|tdio.h>.|
|000037b0| 58 0a 58 23 69 6e 63 6c | 75 64 65 20 22 6d 65 6d |X.X#incl|ude "mem|
|000037c0| 6c 69 6e 74 6f 6b 2e 68 | 22 0a 58 0a 58 6d 61 69 |lintok.h|".X.Xmai|
|000037d0| 6e 28 29 0a 58 7b 0a 58 | 09 69 6e 74 20 2a 70 2c |n().X{.X|.int *p,|
|000037e0| 20 2a 71 3b 0a 58 0a 58 | 09 69 66 20 28 4d 41 4c | *q;.X.X|.if (MAL|
|000037f0| 4c 4f 43 5f 4c 49 4e 54 | 4f 4b 28 70 2c 20 31 30 |LOC_LINT|OK(p, 10|
|00003800| 30 2c 20 69 6e 74 29 20 | 3d 3d 20 4e 55 4c 4c 29 |0, int) |== NULL)|
|00003810| 0a 58 09 09 66 61 69 6c | 28 22 63 61 6e 27 74 20 |.X..fail|("can't |
|00003820| 6d 61 6c 6c 6f 63 20 31 | 30 30 20 69 6e 74 73 5c |malloc 1|00 ints\|
|00003830| 6e 22 29 3b 0a 58 09 65 | 6c 73 65 0a 58 09 09 73 |n");.X.e|lse.X..s|
|00003840| 75 63 63 65 65 64 28 22 | 31 30 30 20 69 6e 74 73 |ucceed("|100 ints|
|00003850| 20 6d 61 6c 6c 6f 63 27 | 64 5c 6e 22 29 3b 0a 58 | malloc'|d\n");.X|
|00003860| 0a 58 09 28 76 6f 69 64 | 29 20 52 45 41 4c 4c 4f |.X.(void|) REALLO|
|00003870| 43 5f 4c 49 4e 54 4f 4b | 28 70 2c 20 32 30 30 2c |C_LINTOK|(p, 200,|
|00003880| 20 69 6e 74 29 3b 0a 58 | 09 69 66 20 28 70 20 3d | int);.X|.if (p =|
|00003890| 3d 20 4e 55 4c 4c 29 0a | 58 09 09 66 61 69 6c 28 |= NULL).|X..fail(|
|000038a0| 22 63 61 6e 27 74 20 72 | 65 61 6c 6c 6f 63 20 32 |"can't r|ealloc 2|
|000038b0| 30 30 20 69 6e 74 73 5c | 6e 22 29 3b 0a 58 09 65 |00 ints\|n");.X.e|
|000038c0| 6c 73 65 0a 58 09 09 73 | 75 63 63 65 65 64 28 22 |lse.X..s|ucceed("|
|000038d0| 32 30 30 20 69 6e 74 73 | 20 72 65 61 6c 6c 6f 63 |200 ints| realloc|
|000038e0| 27 64 5c 6e 22 29 3b 0a | 58 0a 58 09 69 66 20 28 |'d\n");.|X.X.if (|
|000038f0| 4d 52 5f 41 4c 4c 4f 43 | 5f 4c 49 4e 54 4f 4b 28 |MR_ALLOC|_LINTOK(|
|00003900| 70 2c 20 32 35 2c 20 69 | 6e 74 29 20 3d 3d 20 4e |p, 25, i|nt) == N|
|00003910| 55 4c 4c 29 0a 58 09 09 | 66 61 69 6c 28 22 63 61 |ULL).X..|fail("ca|
|00003920| 6e 27 74 20 6d 72 5f 61 | 6c 6c 6f 63 20 28 72 65 |n't mr_a|lloc (re|
|00003930| 61 6c 6c 6f 63 29 20 32 | 35 20 69 6e 74 73 5c 6e |alloc) 2|5 ints\n|
|00003940| 22 29 3b 0a 58 09 65 6c | 73 65 0a 58 09 09 73 75 |");.X.el|se.X..su|
|00003950| 63 63 65 65 64 28 22 32 | 35 20 69 6e 74 73 20 6d |cceed("2|5 ints m|
|00003960| 72 5f 61 6c 6c 6f 63 27 | 64 20 28 72 65 61 6c 6c |r_alloc'|d (reall|
|00003970| 6f 63 27 64 29 5c 6e 22 | 29 3b 0a 58 0a 58 09 69 |oc'd)\n"|);.X.X.i|
|00003980| 66 20 28 43 41 4c 4c 4f | 43 5f 4c 49 4e 54 4f 4b |f (CALLO|C_LINTOK|
|00003990| 28 71 2c 20 35 30 30 2c | 20 69 6e 74 29 20 3d 3d |(q, 500,| int) ==|
|000039a0| 20 4e 55 4c 4c 29 0a 58 | 09 09 66 61 69 6c 28 22 | NULL).X|..fail("|
|000039b0| 63 61 6e 27 74 20 63 61 | 6c 6c 6f 63 20 35 30 30 |can't ca|lloc 500|
|000039c0| 20 69 6e 74 73 5c 6e 22 | 29 3b 0a 58 09 65 6c 73 | ints\n"|);.X.els|
|000039d0| 65 0a 58 09 09 73 75 63 | 63 65 65 64 28 22 35 30 |e.X..suc|ceed("50|
|000039e0| 30 20 69 6e 74 73 20 63 | 61 6c 6c 6f 63 27 64 5c |0 ints c|alloc'd\|
|000039f0| 6e 22 29 3b 0a 58 09 71 | 5b 30 5d 20 3d 20 30 3b |n");.X.q|[0] = 0;|
|00003a00| 0a 58 09 46 52 45 45 5f | 4c 49 4e 54 4f 4b 28 71 |.X.FREE_|LINTOK(q|
|00003a10| 29 3b 0a 58 0a 58 09 46 | 52 45 45 5f 4c 49 4e 54 |);.X.X.F|REE_LINT|
|00003a20| 4f 4b 28 70 29 3b 0a 58 | 09 70 20 3d 20 4e 55 4c |OK(p);.X|.p = NUL|
|00003a30| 4c 3b 0a 58 09 69 66 20 | 28 4d 52 5f 41 4c 4c 4f |L;.X.if |(MR_ALLO|
|00003a40| 43 5f 4c 49 4e 54 4f 4b | 28 70 2c 20 31 30 30 30 |C_LINTOK|(p, 1000|
|00003a50| 2c 20 69 6e 74 29 20 3d | 3d 20 4e 55 4c 4c 29 0a |, int) =|= NULL).|
|00003a60| 58 09 09 66 61 69 6c 28 | 22 63 61 6e 27 74 20 6d |X..fail(|"can't m|
|00003a70| 72 5f 61 6c 6c 6f 63 20 | 28 6d 61 6c 6c 6f 63 29 |r_alloc |(malloc)|
|00003a80| 20 31 30 30 30 20 69 6e | 74 73 5c 6e 22 29 3b 0a | 1000 in|ts\n");.|
|00003a90| 58 09 65 6c 73 65 0a 58 | 09 09 73 75 63 63 65 65 |X.else.X|..succee|
|00003aa0| 64 28 22 31 30 30 30 20 | 69 6e 74 73 20 6d 72 5f |d("1000 |ints mr_|
|00003ab0| 61 6c 6c 6f 63 27 64 20 | 28 6d 61 6c 6c 6f 63 27 |alloc'd |(malloc'|
|00003ac0| 64 29 5c 6e 22 29 3b 0a | 58 0a 58 09 43 41 4c 4c |d)\n");.|X.X.CALL|
|00003ad0| 4f 43 5f 4f 52 5f 45 4c | 53 45 5f 4c 49 4e 54 4f |OC_OR_EL|SE_LINTO|
|00003ae0| 4b 28 70 2c 20 35 30 2c | 20 69 6e 74 29 3b 0a 58 |K(p, 50,| int);.X|
|00003af0| 09 73 75 63 63 65 65 64 | 28 22 35 30 20 69 6e 74 |.succeed|("50 int|
|00003b00| 73 20 63 61 6c 6c 6f 63 | 27 64 20 28 6f 72 20 65 |s calloc|'d (or e|
|00003b10| 6c 73 65 29 5c 6e 22 29 | 3b 0a 58 09 4d 41 4c 4c |lse)\n")|;.X.MALL|
|00003b20| 4f 43 5f 4f 52 5f 45 4c | 53 45 5f 4c 49 4e 54 4f |OC_OR_EL|SE_LINTO|
|00003b30| 4b 28 70 2c 20 31 30 30 | 2c 20 69 6e 74 29 3b 0a |K(p, 100|, int);.|
|00003b40| 58 09 73 75 63 63 65 65 | 64 28 22 31 30 30 20 69 |X.succee|d("100 i|
|00003b50| 6e 74 73 20 6d 61 6c 6c | 6f 63 27 64 20 28 6f 72 |nts mall|oc'd (or|
|00003b60| 20 65 6c 73 65 29 5c 6e | 22 29 3b 0a 58 09 52 45 | else)\n|");.X.RE|
|00003b70| 41 4c 4c 4f 43 5f 4f 52 | 5f 45 4c 53 45 5f 4c 49 |ALLOC_OR|_ELSE_LI|
|00003b80| 4e 54 4f 4b 28 70 2c 20 | 32 30 30 2c 20 69 6e 74 |NTOK(p, |200, int|
|00003b90| 29 3b 0a 58 09 73 75 63 | 63 65 65 64 28 22 32 30 |);.X.suc|ceed("20|
|00003ba0| 30 20 69 6e 74 73 20 72 | 65 61 6c 6c 6f 63 27 64 |0 ints r|ealloc'd|
|00003bb0| 20 28 6f 72 20 65 6c 73 | 65 29 5c 6e 22 29 3b 0a | (or els|e)\n");.|
|00003bc0| 58 0a 58 23 75 6e 64 65 | 66 20 45 52 52 4f 52 5f |X.X#unde|f ERROR_|
|00003bd0| 45 58 49 54 5f 4c 49 4e | 54 4f 4b 0a 58 23 64 65 |EXIT_LIN|TOK.X#de|
|00003be0| 66 69 6e 65 20 45 52 52 | 4f 52 5f 45 58 49 54 5f |fine ERR|OR_EXIT_|
|00003bf0| 4c 49 4e 54 4f 4b 28 6e | 65 6c 65 6d 2c 20 73 69 |LINTOK(n|elem, si|
|00003c00| 7a 65 29 20 5c 0a 58 09 | 66 61 69 6c 28 22 6d 65 |ze) \.X.|fail("me|
|00003c10| 6d 6f 72 79 20 61 6c 6c | 6f 63 61 74 69 6f 6e 20 |mory all|ocation |
|00003c20| 66 61 69 6c 65 64 5c 6e | 22 29 3b 0a 58 0a 58 09 |failed\n|");.X.X.|
|00003c30| 4d 52 5f 41 4c 4c 4f 43 | 5f 4f 52 5f 45 4c 53 45 |MR_ALLOC|_OR_ELSE|
|00003c40| 5f 4c 49 4e 54 4f 4b 28 | 70 2c 20 34 30 30 2c 20 |_LINTOK(|p, 400, |
|00003c50| 69 6e 74 29 3b 0a 58 09 | 73 75 63 63 65 65 64 28 |int);.X.|succeed(|
|00003c60| 22 34 30 30 20 69 6e 74 | 73 20 6d 72 5f 61 6c 6c |"400 int|s mr_all|
|00003c70| 6f 63 27 64 20 28 72 65 | 61 6c 6c 6f 63 27 64 29 |oc'd (re|alloc'd)|
|00003c80| 20 28 6f 72 20 65 6c 73 | 65 29 5c 6e 22 29 3b 0a | (or els|e)\n");.|
|00003c90| 58 0a 58 09 65 78 69 74 | 28 30 29 3b 0a 58 09 72 |X.X.exit|(0);.X.r|
|00003ca0| 65 74 75 72 6e 20 30 3b | 09 2f 2a 20 73 68 75 74 |eturn 0;|./* shut|
|00003cb0| 73 20 75 70 20 48 50 2d | 55 58 20 6c 69 6e 74 20 |s up HP-|UX lint |
|00003cc0| 2a 2f 0a 58 7d 0a 58 0a | 58 66 61 69 6c 28 73 29 |*/.X}.X.|Xfail(s)|
|00003cd0| 0a 58 09 63 68 61 72 20 | 2a 73 3b 0a 58 7b 0a 58 |.X.char |*s;.X{.X|
|00003ce0| 09 66 70 75 74 73 28 73 | 2c 20 73 74 64 6f 75 74 |.fputs(s|, stdout|
|00003cf0| 29 3b 0a 58 09 65 78 69 | 74 28 31 29 3b 0a 58 7d |);.X.exi|t(1);.X}|
|00003d00| 0a 58 0a 58 73 75 63 63 | 65 65 64 28 73 29 0a 58 |.X.Xsucc|eed(s).X|
|00003d10| 09 63 68 61 72 20 2a 73 | 3b 0a 58 7b 0a 58 09 66 |.char *s|;.X{.X.f|
|00003d20| 70 75 74 73 28 73 2c 20 | 73 74 64 6f 75 74 29 3b |puts(s, |stdout);|
|00003d30| 0a 58 09 72 65 74 75 72 | 6e 3b 0a 58 7d 0a 45 4e |.X.retur|n;.X}.EN|
|00003d40| 44 5f 4f 46 5f 74 5f 6d | 65 6d 6c 69 6e 74 6f 6b |D_OF_t_m|emlintok|
|00003d50| 2e 63 0a 69 66 20 74 65 | 73 74 20 31 34 33 38 20 |.c.if te|st 1438 |
|00003d60| 2d 6e 65 20 60 77 63 20 | 2d 63 20 3c 74 5f 6d 65 |-ne `wc |-c <t_me|
|00003d70| 6d 6c 69 6e 74 6f 6b 2e | 63 60 3b 20 74 68 65 6e |mlintok.|c`; then|
|00003d80| 0a 20 20 20 20 65 63 68 | 6f 20 73 68 61 72 3a 20 |. ech|o shar: |
|00003d90| 5c 22 74 5f 6d 65 6d 6c | 69 6e 74 6f 6b 2e 63 5c |\"t_meml|intok.c\|
|00003da0| 22 20 75 6e 70 61 63 6b | 65 64 20 77 69 74 68 20 |" unpack|ed with |
|00003db0| 77 72 6f 6e 67 20 73 69 | 7a 65 21 0a 66 69 0a 23 |wrong si|ze!.fi.#|
|00003dc0| 20 65 6e 64 20 6f 66 20 | 6f 76 65 72 77 72 69 74 | end of |overwrit|
|00003dd0| 69 6e 67 20 63 68 65 63 | 6b 0a 66 69 0a 65 63 68 |ing chec|k.fi.ech|
|00003de0| 6f 20 73 68 61 72 3a 20 | 45 6e 64 20 6f 66 20 73 |o shar: |End of s|
|00003df0| 68 65 6c 6c 20 61 72 63 | 68 69 76 65 2e 0a 65 78 |hell arc|hive..ex|
|00003e00| 69 74 20 30 0a 0a | |it 0.. | |
+--------+-------------------------+-------------------------+--------+--------+